GridView1使用Label ,TextBox 及隐藏Label,让TextBox使用日期控件EditItemTemplate效果,并后台获其取值,

本文详细介绍了在ASP.NET开发环境下,如何通过模板字段实现开发票日期的显示和编辑功能,包括使用服务器控件如Label和TextBox,以及CalendarExtender用于日期选择,并讨论了隐藏控件的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前台:

<asp:TemplateField HeaderText="开发票日期">
   <ItemTemplate>
  <asp:Label ID="Invoice_date_0" runat="server" Text='<%# Bind("Invoice_date","{0:d}") %>' ></asp:Label> 

</ItemTemplate>
   <EditItemTemplate>
  <asp:TextBox ID="Invoice_date" runat="server" Text='<%# Bind("Invoice_date","{0:d}") %>' ></asp:TextBox>
  <asp:CalendarExtender ID="Txt_Confirm_Date_CalendarExtender" runat="server" Enabled="True"
    TargetControlID="Invoice_date">
   </asp:CalendarExtender>
  </EditItemTemplate>

  <ControlStyle Width="80px" />
 <HeaderStyle Width="80px" />
  </asp:TemplateField>

隐藏控件:

   <asp:TemplateField HeaderText="ID" Visible="false">
   <ItemTemplate>
   <asp:Label ID="ID_R" runat="server" Text='<%# Eval("ID") %>' />
   </ItemTemplate>
   </asp:TemplateField>

后台:

 

       string Ror_id = ((Label)this.GridView1.Rows[e.RowIndex].FindControl("ID_R")).Text.ToString();//取得隐藏值

        string Invoice_date = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Invoice_date")).Text.ToString();//开发票日期

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

那小x的传说

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值