本文介绍了如何绑定gridview中的下拉列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个按类别搜索的下拉列表。我需要帮助在页面加载时绑定我的gridview,但同时,我还有一个select命令作为投票I have a dropdown list to search by categories. I need help to bind my gridview at page load, but at the same time, I also have a select command as votes推荐答案<asp:templatefield headertext="Some Text" xmlns:asp="#unknown"><itemtemplate><asp:dropdownlist id="ddlAnything" runat="server" /></itemtemplate></asp:templatefield> b $ b// In page Load Bing GridViewGridView1.DataSource = <Your DataSource>;GridView1.DataBind();// In RowDataBound Event Of GridView Bind Your DropDownprotected void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e){if (e.Row.RowType == DataControlRowType.DataRow) { // your code to get data DropDownList ddlAnything= (DropDownList)e.Row.FindControl("ddlAnything"); ddlAnything.DataSource = dataset.Tables[0].DefaultView; ddlAnything.DataValueField = "ValueField"; ddlAnything.DataTextField = "TextField"; ddlAnything.DataBind(); }} 这篇关于如何绑定gridview中的下拉列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-11 16:08