在编辑时绑定到Templatefield中的下拉列表 [英] bound drop down in Templatefield at edit time
问题描述
我具有带有Edit,Cancel,delete的gridview
gridview中有休假类型的列,它显示休假类型(例如)
1)病了
2)因果
3)年度等)
它显示1个.
当用户单击编辑"按钮时,我要显示下拉菜单
应该与db(sqlserver)绑定
怎么做???
正如我们通常绑定在asp.net中的下拉菜单一样,需要做的事情
我的代码
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
<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
推荐答案
在gridview的row_bound方法处绑定下拉列表
Bind dropdownlist at row_bound method of gridview
我以为你说过:
I thought you said:
当用户单击编辑"按钮时,我想显示下拉列表
when user click on "Edit" button I want to show the drop down
您也可以通过编程方式执行此操作.
您需要处理GridView
的RowEditing
事件以绑定DropDownList.
You can do this programmatically as well.
You need to handle RowEditing
event of the GridView
to bind the DropDownList.
< asp:DropDownList id ="gvddlleavestype" runat ="server" width ="150px" selectedvalue =''<%#Bind("LeaveType")>''></asp:DropDownList>
<asp:DropDownList id="gvddlleavestype" runat="server" width="150px" selectedvalue=''<%# Bind("LeaveType") >'' ></asp:DropDownList>
在gridview的row_bound方法处绑定下拉列表.
检查此URL.有你的解决方案
在ASP.NET 2.0中可编辑的GridView [
Bind dropdownlist at row_bound method of gridview.
check this URL. it have your solution
Editable GridView in ASP.NET 2.0[^]
这篇关于在编辑时绑定到Templatefield中的下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!