<asp:GridView ID="GVBeneficiary" runat="server" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333"
onrowcancelingedit="GVBeneficiary_RowCancelingEdit"
onrowediting="GVBeneficiary_RowEditing"
onrowupdating="GVBeneficiary_RowUpdating"
onrowdatabound="GVBeneficiary_RowDataBound">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:TemplateField HeaderText="ID">
<ItemTemplate>
<asp:Label runat="server" ID="lblID" Text='<%#Bind("id") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="AccountNumber">
<ItemTemplate>
<asp:TextBox runat="server" ID="txtAccountNumber" Text='<%#Bind("AccountNo") %>' ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:TextBox runat="server" ID="txtName" Text='<%#Bind("Name") %>' ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PhoneNumber">
<ItemTemplate>
<asp:TextBox runat="server" ID="txtPhoneNumber" Text='<%#Bind("PhoneNumber") %>' ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="BankName">
<ItemTemplate>
<asp:DropDownList runat="server" ID="ddlBankNme">
<asp:ListItem Value="0">Select</asp:ListItem>
<asp:ListItem Value="1">State Bank of India</asp:ListItem>
<asp:ListItem Value="2">Indian Bank</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="BranchNumber">
<ItemTemplate>
<asp:TextBox runat="server" ID="txtBranchNumber" Text='<%#Bind("BranchName") %>' ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="false" >
<ItemTemplate>
<asp:HiddenField runat="server" ID="txtBankName" Value='<%#Bind("BankName") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="Red" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
</asp:GridView>
C#:
protected void GVBeneficiary_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HiddenField txthidden = ((HiddenField)e.Row.FindControl("txtBankName"));
DropDownList ddlhidden = ((DropDownList)e.Row.FindControl("ddlBankNme"));
ddlhidden.SelectedValue = txthidden.Value;
}
}
No comments:
Post a Comment