从数据库绑定下拉列表 [英] bind dropdown from database
本文介绍了从数据库绑定下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在asp.net中更新鲜。
i在网格中有一个下拉列表,里面有列表项。
i不能绑定值使用Gridview.Databind()中的itemtemplate中的数据库
这里是我的下拉列表
i am fresher in asp.net.
i have a dropdownlist in grid with list items in it.
i cant bind the values from database in itemtemplate while using Gridview.Databind()
here is my dropdownlist
<pre lang="HTML">
<asp:DropDownList ID="DropDownList3" runat="server" Height="16px" Width="53px" SelectedValue='<%# Bind("EdnLevel") %>' >
<asp:ListItem Selected="True">Nos</asp:ListItem>
<asp:ListItem>Kg</asp:ListItem>
<asp:ListItem>Ltr</asp:ListItem>
</asp:DropDownList>
推荐答案
<asp:dropdownlist id="DropDownList3" runat="server" height="16px" width="53px" selectedvalue="<%# Bind("EdnLevel") %>" xmlns:asp="#unknown">
<asp:listitem>Nos</asp:listitem>
<asp:listitem>Kg</asp:listitem>
<asp:listitem>Ltr</asp:listitem>
</asp:dropdownlist>
and now you have to find the dropdownlist within grid
on rowdatabound event
eg.
dropdownlist objddl=(dropdownlist)grid1.rows[rowindex].fincontrol["dropdownlist id"];
objddl.SelectedValue="Assiged The Data What U Want"
您可以访问以下链接,这是非常自我解释的...... < br $> b $ b
希望能有所帮助...... :)
http:// stackoverflow.com/questions/7227510/asp-net-right-way-to-populate-a-dropdown-list-from-database [ ^ ]
You can visit the following link which is pretty much self explanatory...
hope that will help... :)
http://stackoverflow.com/questions/7227510/asp-net-right-way-to-populate-a-dropdown-list-from-database[^]
这篇关于从数据库绑定下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文