日期:2014-05-18  浏览次数:20572 次

GRIDVIEW绑定GRIDVIEW数据源参数取值问题
GRIDSVIEW1中有摸版列绑定了另一个GRIDVIEW2,GRIDVIEW2数据根据GRIDVIEW1某列id的值做为参数选取数据表,我的问题是如何得到GRIDVIEW1列id的值,我在GridView1_RowDataBound中写如下代码:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  {
   
  string sql1 = "select * from assort where xh=@id order by item";
  SqlParameter par =new SqlParameter("@id",SqlDbType.Int,4);
  par.value=? 怎样把gridview1中列id的值传给par?  
   
  }

------解决方案--------------------
int userRegisterID = Convert.ToInt32(GridView1.DataKeys[e.Row.RowIndex].Value);
------解决方案--------------------
把id设为关键字,用一楼的就行,如果需要添加选择按钮列的话把e.Row.RowIndex换成GridView1..SelectedIndex