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

前台:

<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();//开发票日期

 

你可能感兴趣的:(Date,server,String,asp,textbox)