我有一个使用 EmptyDataTemplate 的 ASP.NET GridView。在 EmptyDataTemplate 内,我有一些文本框和一个用于插入记录的提交按钮。当我尝试访问代码隐藏文件中的 ID 时,它们没有显示出来。
我的代码:
<asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black"
GridLines="Vertical">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="BankName" HeaderText="Bank Name" />
<asp:BoundField DataField="IFSCCode" HeaderText="IFSC Code" />
<asp:BoundField DataField="MICRCODE" HeaderText="MICR Code" />
<asp:BoundField DataField="BranchName" HeaderText="Branch Name" />
<asp:BoundField DataField="Address" HeaderText="Address" />
</Columns>
<EmptyDataTemplate>
<div style="border: 1px solid #ccc; width: auto; margin: 20px 470px;">
<table border="0" cellpadding="2" cellspacing="0">
<tr>
<th colspan="3" bgcolor="#1e7c9a" style="color: White">
Please Enter Your Bank Details
</th>
</tr>
<tr>
<td>
Bank Name
</td>
<td>
<asp:TextBox ID="txtBankname" runat="server" Width="180px" />
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ErrorMessage="Required"
ForeColor="Red" ControlToValidate="txtBankname" runat="server" Width="120" />
</td>
</tr>
<tr>
<td>
IFSC Code
</td>
<td>
<asp:TextBox ID="txtIfsccode" runat="server" Width="180px" />
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ErrorMessage="Required"
ForeColor="Red" ControlToValidate="txtIfsccode" runat="server" />
</td>
</tr>
<tr>
<td>
MICR Code
</td>
<td>
<asp:TextBox ID="txtMicrcode" runat="server" Width="180px" />
</td>
<td>
</td>
</tr>
<tr>
<td>
Branch Name
</td>
<td>
<asp:TextBox ID="txtBranchName" runat="server" Width="180px" />
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" ErrorMessage="Required"
Display="Dynamic" ForeColor="Red" ControlToValidate="txtBranchName" runat="server" />
</td>
</tr>
<tr>
<td>
Address
</td>
<td>
<asp:TextBox ID="txtAddress" runat="server" TextMode="MultiLine" />
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" ErrorMessage="Required"
ForeColor="Red" ControlToValidate="txtAddress" runat="server" />
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btn" Text="Submit" runat="server" OnClick="InsertDetails"/>
</td>
<td>
</td>
</tr>
</table>
</div>
</EmptyDataTemplate>
<FooterStyle BackColor="#CCCC99" />
<HeaderStyle BackColor="#1e7c9a" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle BackColor="#F7F7DE" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FBFBF2" />
<SortedAscendingHeaderStyle BackColor="#848384" />
<SortedDescendingCellStyle BackColor="#EAEAD3" />
<SortedDescendingHeaderStyle BackColor="#575357" />
</asp:GridView>