ASP.NET,点击GridView中的详细按钮获取点击那行的值 仍用gridview显示
主页面已经写好可以跳转
- C# code
protected void GridViewD_RowCommand(object sender, GridViewCommandEventArgs e) { if ("EditRow".Equals(e.CommandName)) { string id = e.CommandArgument.ToString(); this.ModalPopupExtender1.Show(); } }
但是次页面不显示内容 是一个空的表框
次表的GridView是用GridView.Datasource=ds;GridView.DataBind();绑定的
不用sqlDataSource
也不能用GridView自带的选择
- C# code
protected void Page_Load(object sender, EventArgs e) { if (getuser.Strcomid == null) Response.Redirect("index.aspx"); if (!Page.IsPostBack) { System.Data.SqlClient.SqlConnection sqlConn = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["dbsysConnectionString"].ConnectionString.ToString()); sqlConn.Open(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter("SELECT ents_sid,ents_pid,ents_comid, ents_code,ents_type, ents_mid, pro_ape, pro_spe, ents_qty, ents_wid,ents_price,ents_amount, ents_discount, ents_disrate,ents_gamount,ents_present,ents_oth1,ents_rem FROM dbo.GetEntryDinfo where ents_mid='" + get_value.Getcontrolstr + "' and ents_type=11 and ents_comid='" + getuser.Strcomid + "'", sqlConn); da.Fill(dt); da.Dispose(); sqlConn.Close(); GridViewD.DataSource = dt; //this.GridViewD.DataKeyNames = new string[] { "ents_sid" }; GridViewD.DataBind(); } }
------解决方案--------------------------------------------------------
传个ID重新绑定
------解决方案--------------------------------------------------------
通过你那个跳转连接传一个值,然后你获取,根据这个你你去查询重新绑定另一个