gridview内部的下拉列表未从数据库中填充值 [英] Dropdowns inside the gridview are not populating values from Database

查看:99
本文介绍了gridview内部的下拉列表未从数据库中填充值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在gridview中有两个下拉菜单
像DDL1和DDL2
在DDL1的更改事件中,第二个下拉列表DDL2被绑定.
但是我的问题是在加载Ist时间页面时,我的两个下拉列表都没有填充来自数据库的值.
第二个Dropdown DDL2我可以理解它不会绑定,但Ist Dropdown DDL1应该显示数据库中的值.
我该怎么办?

谢谢

Hi,

I have two dropdown inside the gridview
Like DDL1 and DDL2
On the change event of DDL1 second dropdown DDL2 is binding.
But my problem is when Ist time page is loading my both dropdowns are not populating value which are coming from database.
SEcond Dropdown DDL2 i can understand it would not bound but Ist Dropdown DDL1 should display value from database .
How should i do it?

Thanks

推荐答案

try this ,first take a template field then add item template,then inside edit template put the dropdown as follow...

<asp:templatefield headertext="Status" sortexpression="with_status" xmlns:asp="#unknown">

<asp:label id="Label1" runat="server" text="<%# Bind("with_status") %>">



<asp:dropdownlist id="DropDownList1" runat="server">
<asp:listitem value="0">-Select-
<asp:listitem value="1">pending
<asp:listitem value="2">completed






aspx.cs

on rowupdating put the following code

DropDownList ddl2 = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("DropDownList1");
if (ddl2.SelectedValue.ToString() != "0")
{
SqlDataSource1.UpdateParameters["with_status"].DefaultValue = ddl2.SelectedItem.ToString();

}


这篇关于gridview内部的下拉列表未从数据库中填充值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆