我用GridView绑定好数据了,但是,如何查看详细数据呢?为什么我指定绑定数据的位置后还是有问题?请叫下,如何在GridView中查看详细数据。或者是编辑详细数据?
public static SqlConnection con;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
string str;
string str2 = Page.Request["ID"].ToString();
SqlConnection mycon = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
mycon.Open();
SqlDataAdapter myada = new SqlDataAdapter("select * from BE_Information where ID='"+ str2 +"'",mycon);
DataSet ds = new DataSet();
myada.Fill(ds, "BE_Information");
DataRowView rowview = ds.Tables["BE_Information"].DefaultView[0];
this.labBE_name.Text = ds.Tables["BE_name"].ToString();
this.lab_Type.Text=ds.Tables["Type"].ToString();
this.lab_StopUsing.Text=ds.Tables["SropUsing"].ToString();
this.lab_Register.Text=ds.Tables["Register"].ToString();
this.txtMemberNumber.Text=ds.Tables["MemberNumber"].ToString();
mycon.Close(); }
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
public static SqlConnection con;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
string str;
string str2 = Page.Request["ID"].ToString();
SqlConnection mycon = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
mycon.Open();
SqlDataAdapter myada = new SqlDataAdapter("select * from BE_Information where ID='"+ str2 +"'",mycon);
DataSet ds = new DataSet();
myada.Fill(ds, "BE_Information");
DataRowView rowview = ds.Tables["BE_Information"].DefaultView[0];
this.labBE_name.Text = ds.Tables["BE_name"].ToString();
this.lab_Type.Text=ds.Tables["Type"].ToString();
this.lab_StopUsing.Text=ds.Tables["SropUsing"].ToString();
this.lab_Register.Text=ds.Tables["Register"].ToString();
this.txtMemberNumber.Text=ds.Tables["MemberNumber"].ToString();
mycon.Close(); }
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
换成
string str2 = Request.QueryString["ID"].ToString();