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

-----------__如何取到GridView中Cell的值?
1,abc.aspx

protected   void   View_ItemDataBound(object   sender,   GridViewRowEventArgs   e)
{
    if(e.Row.Cells.Count   > 0)
    {
//lbDate.Text=e.Row.Cells[0].Text;
lbDate.Text=e.Row.RowIndex.ToString();
e.Row.Cells[1].Attributes.Add( "onclick ",   "PopupArea(event,   'divWrite ') ");
e.Row.Cells[1].Attributes[ "style "]= "CURSOR:   hand ";  
    }
}
......
<script   src= "js/jsPopup.js "   type= "text/javascript "> </script>

2,xyz.js

function   PopupArea(e,   areaId)
{    
if   (e.pageX   ||   e.pageY)
{
posx   =   e.pageX;
posy   =   e.pageY;
}
else  
if   (e.clientX   ||   e.clientY)
{
posx   =   e.clientX   +   document.body.scrollLeft;
posy   =   e.clientY   +   document.body.scrollTop;
//posy   =   e.clientY   +   document.body.scrollTop;
}

var   area   =   GetArea(areaId);
area.popuparea(posx,   posy);
}
這裡的PopupArea(e,   areaId)顯示abc.aspx頁裡的一個div,裡面有一個label,但是我不知道當點擊第i行時怎樣取得第這一行的Cells[0]的值?

謝謝!

------解决方案--------------------
e.srcElement.parentElement.cells[0].innerText;