Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have gridview with Edit,cancel, delete

there is col of leave type in gridview it shows leave type (eg)
1)sick
2)causal
3)Annual etc)

It shows 1 either of them.
when user click on "Edit" button I want to show the drop down which
should be bound with db(sqlserver)
How to do that ???

as we usually bound drop down in asp.net same thing need to be done
My Code

XML
<asp:TemplateField HeaderText="LeaveType">
                     <EditItemTemplate>
                        <asp:DropDownList ID="gvddlleavestype" runat="server" Width="150px"></asp:DropDownList>
                     </EditItemTemplate>
                     <ItemTemplate>
                         <asp:Label ID="Label5" runat="server" Text='<%# Bind("LeaveType") %>'></asp:Label>
                     </ItemTemplate>
                 </asp:TemplateField>


waiting
Posted

Lalit Kumar wrote:
Bind dropdownlist at row_bound method of gridview

I thought you said:

qasimidl wrote:
when user click on "Edit" button I want to show the drop down


You can do this programmatically as well.
You need to handle RowEditing event of the GridView to bind the DropDownList.
 
Share this answer
 
<asp:DropDownList id="gvddlleavestype" runat="server" width="150px" selectedvalue='<%# Bind("LeaveType") >' ></asp:DropDownList>
 
Share this answer
 
v6
Bind dropdownlist at row_bound method of gridview.

check this URL. it have your solution
Editable GridView in ASP.NET 2.0[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900