GridView1使用Label ,TextBox 及隐藏Label,让TextBox使用日期控件EditItemTemplate效果,并后台获其取值,
2011-09-02 21:39
369 查看
前台:
<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();//开发票日期
<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();//开发票日期
相关文章推荐
- .NET 2.0 Web控件GridView的使用:如何使用隐藏的主键列
- ASP.NET2.0中的GRIDVIEW控件在使用TemplateField中的LinkButton时如何在RowCommand事件中找到当前行index的方法
- gridview 实现排序 (在不是使用sqlDataSource控件,而在后台编码绑定gridview时,指定那个字段排序时使用。本例用了单层结构,可修改后应用于多层)
- 窗体自动隐藏停靠开源控件Dock控件的使用(WeiFenLuo.winFormsUI.Docking.dll的使用(停靠效果))
- 使用JQuery 做仿asp.net 中的gridview 控件编辑效果
- 如何在使用了TemplateField的GridView控件中访问Cell值?
- 使用JQuery 做仿asp.net 中的gridview 控件编辑效果
- GridView中,在ItemTemplate下使用button与后台交互
- ASP.NET中TextBox使用Ajax控件显示日期不全的问题解决方法
- ASP.NET中TextBox使用Ajax控件显示日期不全的问题解决方法
- 使用GridView的TemplateField和EditItem Template
- ASP.NET 2.0数据教程之十二:在GridView控件中使用TemplateField(转)
- [控件使用]手工设置Gridview的pagerTemplate
- Asp .NET使用控件常见问题大全(设计时选中、Button、TextBox、DropDownList、GridView、UpdatePanel 等)
- ASP.NET2.0中的GRIDVIEW控件在使用TemplateField中的LinkButton时如何在RowCommand事件中找到当前行index的方法
- 在gridview的页脚的textbox等控件通过javascript取值
- GridView后台自动添加行、列,行列不固定,并且再列里面添加服务器控件,然后取值
- ASP.NET(C#)中将TextBox控件的Readonly属性设置为True时后台直接取值取不到的解决方案
- ASP.NET2.0中的GRIDVIEW控件在使用TemplateField中的LinkButton时如何在RowCommand事件中找到当前行index的方法
- 在ASP.NET 2.0中操作数据之十二:在GridView控件中使用TemplateField