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

求救]怎么获取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 ");
      }
    }

 

向各位大虾求救,期待回复,先谢谢了!

------解决方案--------------------
e.Item.Attributes.Add( "onclick ", "window.open( 'ShowCustomer.aspx?id=a ', 'main ', 'height=500,width=470,top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no ') ");

这里你都写死了是a了。你断点看看string的这个A是多少
string a=e.Item.Cells[0].Text;
就是这个。