日期:2014-05-19  浏览次数:20686 次

[求救]怎么获取DataGridbe当前行每一列的值

图片地址:http://www.cvbbs.cn/attach.aspx?attachid=2567

如上图所示,我怎么获取DataGridCustomer被选择行(即黄色背景行)每列的值,即客户代码的值,传递给下面代码ID。

 

代码如下:

    private   void   DataGridCustomer_ItemDataBound(object   sender,   System.Web.UI.WebControls.DataGridItemEventArgs   e)
    {
      if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
      {
        e.Item.Attributes.Add( "onmouseover ", "c=this.style.backgroundColor;this.style.backgroundColor= '#ffffcc ' ");
        e.Item.Attributes.Add( "onclick ", "window.open( 'ShowCustomer.aspx?id=?? ', 'main ', 'height=500,width=470,top=0,   left=0,   toolbar=no,   menubar=no,   scrollbars=yes,   resizable=no,location=no,   status=no ') ");
        e.Item.Attributes.Add( "onmouseout ", "this.style.backgroundColor=c ");
      }
    }

 

期待回复,先谢谢了!


------解决方案--------------------
private void Dat_Xianshi_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.Label1.Text= Dat_Xianshi.Items[Dat_Xianshi.SelectedIndex].Cells[1].Text;
}
这样就可以获得 DataGrid对象Dat_Xianshi中 选中列第二个单元格的值
刚刚做出来希望对你有帮助!~!~