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

++++++++++再问怎样获得GridView单元格的值,或在javascript取得值后怎样传递给c#后台?
昨天的帖子:
http://community.csdn.net/Expert/topic/5534/5534056.xml?temp=2.007693E-02

-----------------
我用document.getElementById( "lbDate ").innerText=e.srcElement.parentElement.cells[0].innerText;得到值後,在下面代碼中stimePrt取不到lbDate.Text值,請教大師!
    SqlParameter   uidPrt=new   SqlParameter( "@uid ",SqlDbType.VarChar);        
    SqlParameter   contentPrt=new   SqlParameter( "@content ",SqlDbType.VarChar);
    SqlParameter   sdatePrt=new   SqlParameter( "@sdate ",SqlDbType.VarChar);  
    SqlParameter   stimePrt=new   SqlParameter( "@stime ",SqlDbType.VarChar);  
   
    uidPrt.Value= "11122153 ";
    contentPrt.Value=txt1.Text;
    sdatePrt.Value=lbToday.Text;
    stimePrt.Value=lbDate.Text;



------解决方案--------------------
label的值动态改变,后台拿不到
应该加一个hidden field

<input type= "hidden " id= "hdnDate " runat= "server " />

var v = e.srcElement.parentElement.cells[0].innerText;
document.getElementById( "lbDate ").innerText=v;
document.getElementById( "hdnDate ").value=v;

后台通过hdnDate.Value取值
stimePrt.Value=hdnDate.Value;