假设我在datagrid里绑定了3个列
0列和1列是相关的数据,2列是button列
我点击某一行对应的button,如何得到该列0列具体内容?
谢谢

解决方案 »

  1.   

    how are you handling the click event? if you are doing in DataGrid's ItemCommand event handler, you can use the second parameter e,
     then use  e.Item.Cells[0] or use e.Item.FindControl to location your control in the first columnor if you havevoid Button_Click(Object sender, EventArgs e)
    {
      Button btn = (Button)sender;
      DataGridItem dgi = (DataGridItem)btn.Parent.Parent;  //dgi.Cells[0].Controls[0] or dgi.FindControl("..")
    }
      

  2.   

    datagrid_databind
    dim but as button
    but=e.item.findcontrol("button")
    but.Attributes.Add("onClick","alert('"+e.item.cell(0).text+"')")