GridView中添加层,点击打开,展开此层,反之

在GridView中潜套一个层,点击‘ 打开‘ 展开此层,反之
所用到的JavaScript如下:
      
< script type = " text/javascript " >
  
// <![CDATA[
  function ShowHidden(sid,ev)
  {
    ev 
=  ev  ||  window. event ;
    var target 
=  ev.target  ||  ev.srcElement;
    var oDiv 
=  document.getElementById( " div "   +  sid);
    oDiv.style.display 
=  oDiv.style.display  ==   " none " ? " block " : " none " ;
    target.innerHTML 
=  oDiv.style.display  ==   " none " ? " 显示 " : " 隐藏 " ;
  }
  
// ]]>
   </ script >

在GridView调用的代码如下:
< ItemTemplate >
                            
< div style = " font-weight: bold; background-color: #DEDEDE; " >
             
< span style = " float: right;
                color: Red; cursor: pointer "  οnclick= " ShowHidden( ' <%#Eval("Order_Id") %> ' , event ) " >显示</span></div>

                                
< div style = "  display: none;  "  id = " div<%#Eval( " Order_Id " ) %> " >
                                    
< table >
                                        
< tr >
                                            
< td >
                                                备注:
</ td >
                                            
< td colspan = " 2 " >
                                                
< asp:TextBox ID = " txtordertext "  runat = " server "  Height = " 47px "  TextMode = " MultiLine "  Text = ' <%#Eval("Order_Text") %> '  Width = " 122px " ></ asp:TextBox ></ td >
                                        
</ tr >
                                        
< tr >
                                            
< td >
                                            
</ td >
                                            
< td colspan = " 2 " >
                                                
< asp:Button ID = " btsend "  runat = " server "  Text = " 发货 "  OnClick = " Button1_Click "   /></ td >
                                        
</ tr >
                                    
</ table >
                                
</ div >
                            
</ ItemTemplate >
有的人则可能有点迷惑,我在GridView中添加一个Button,可是我双击这个Button进入到此Button的ONClick事件中,我们怎么才能得到我们所点击的那一行的的Id(也就是我们数据库的主建)值呢?
     我们经常在GirdView的Bound事件中以GridView1.Cell[
0 ].Text得到此行的主建值,那我们怎么才能在GridView事件之外得到该行的Id值呢
     说来说去,GridView也只不过是用Table的原理,所以当我们知道这些,我们就能在TableCell中下手
    下面是Button的OnClick事件的代码
        Button btsend 
=  sender  as  Button;
        TableCell tc 
=  (TableCell)btsend.Parent;
        GridViewRow gvr 
=  (GridViewRow)tc.Parent;
        eWebShop.BLL.Order bllOrder 
=   new  eWebShop.BLL.Order();
        bllOrder.UpdateOrderTextAndSendTime(gvr.Cells[
0 ].Text, ((TextBox)gvr.FindControl( " txtordertext " )).Text, DateTime.Now);
        Response.Redirect(Request.Url.ToString());
    到这里就不用我多说了吧!
   有什么不对的地方,还请各位指点!
注:上面的展开层的js代码是用孟宪会老师的!
^  _  ^  

 效果图如下:
初始图:


点开效果如下

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值