以下是一个页面的代码:
namespace WebApplication1
{
public partial class dingdan : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
string strcnn = ConfigurationManager.ConnectionStrings["s"].ConnectionString;
SqlConnection cnn = new SqlConnection(strcnn);
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "delete from [order] where uid='" + DropDownList1.SelectedValue.Trim() + "' and pid in (select id from sp where name='" + GridView1.SelectedRow.Cells[1].Text.Trim() + "')";
try
{
cnn.Open();
cmd.ExecuteNonQuery();
Response.AddHeader("Refresh", "0");
}
catch (Exception ex)
{
}
finally
{
if (cnn.State == ConnectionState.Open)
cnn.Close();
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("~/login.aspx");
}
protected void Button3_Click(object sender, EventArgs e)
{
Response.Redirect("~/editsp.aspx");
}
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
}
protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
}
}
VS上的界面可以显示,但是调式出来在网页上看不见,求助!
最好是能够写出代码,告诉我怎么做,谢谢!!
pageload是用来初始化的,里面啥都没有,肯定显示不出来
后台代码里也没有看到绑定gridview数据源的代码
一开始GridView的数据源没有设定,也没有绑定。
这个不清楚gridview要显示什么样的数据,怎么从数据库查,
你可以重新写一个方法
protected void BindGrid()
{
string str = "";//引号里的内容为你的数据库查询语句
string strcnn = ConfigurationManager.ConnectionStrings["s"].ConnectionString;
SqlConnection cnn = new SqlConnection(strcnn);
SqlDataAdapter command = new SqlDataAdapter(str, cnn);
DataSet ds = new DataSet();
command.Fill(ds);
DataTable dt = new DataTable();
dt = ds.Tables[0];
DataView myview = new DataView(dt);
GridView1.DataSource = myview;
GridView1.DataBind();
}
然后再在Page_Load这个方法里加上 BindGrid();