Tuesday, June 20, 2023

Use DropDownList in EditTemplate in GridView

 Instead using a TextBox in the EditTemplate of a GridView, if needed you can use a DropdownList , here is a code in HTML page  :

<EditItemTemplate>                        

         <asp:DropDownList ID="type_edit" runat="server" AutoPostBack="true" SelectedValue='<%# Bind("transaction_type") %>' >

                    <asp:ListItem Value="" ></asp:ListItem>

                    <asp:ListItem Value="LOAN">LOAN</asp:ListItem>

                    <asp:ListItem Value="PRINCIPAL PAYMENT">PRINCIPAL PAYMENT</asp:ListItem>

                    <asp:ListItem Value="INTEREST PAYMENT">INTEREST PAYMENT</asp:ListItem>

             </asp:DropDownList>

  </EditItemTemplate>


You do not have to write anything in code behind page.😀😀