如何将带有文本的值从表绑定到asp.net中的dropdownlist [英] how to bind values with text from table to dropdownlist in asp.net
本文介绍了如何将带有文本的值从表绑定到asp.net中的dropdownlist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有桌子->团体
表库伦-> groupno,组名,状态
我还需要使用groupnos将组名绑定到下拉列表
当用户选择组名时,我需要选择选择组号进行用户选择
下拉第一个索引应类似于-"---- select ------"
然后使用组名来限制用户选择一个选项
您能用代码
i have table -> groups
table coulmns -> groupno,groupname,status
i need to bind groupnames to dropdown with groupnos also
when user selected groupname i need to pick select groupno for user selection
dropdown first index should be like - "----select------"
then groupname for restricing the user to select one option
can u help me in code
推荐答案
如果有帮助,请尝试此链接.
需要将全部添加到下面的下拉列表中.
要在下拉列表顶部插入---- select ----,
请参见上面的示例:
dphaircolor.Items.Insert(0,new ListItem("All","All"))); //在顶部选择全部插入
在操纵您的小组时,我认为您可以通过
来处理它 您的SQL where子句
问候,
代数
Hi,
Try this link if could help.
Need to add All to the dropdownlist in the below.
To insert the ----select---- at the top of you dropdown list,
please see example above:
dphaircolor.Items.Insert(0,new ListItem("All", "All")); // Insert All at top selection
In manipulation of your group, I think you could be handle it with
your SQL where clause
Regards,
Algem
嗨 检查此代码.oXMLNodeList = oXMLDoc.GetElementsByTagName("ProductDesc");
如果((oXMLDoc.ChildNodes.Count> = 1)&&(oXMLNodeList.Count> 0))
{
DropDownList2.Items.Clear();
DropDownList2.Items.Add(new ListItem(-选择产品名称-","0"));
for(int intLoop = 0; intLoop< = oXMLNodeList.Count-1; intLoop ++)
{
strPlantId = oXMLDoc.GetElementsByTagName("ProductDesc").Item(intLoop).InnerText;
//strCategoryName = RXMLReservedChrConvert(oXMLDoc.GetElementsByTagName("Product_Name").Item(intLoop).InnerText);
DropDownList2.Items.Add(new ListItem(strPlantId));
}
}
其他
{
DropDownList2.Items.Clear();
DropDownList2.Items.Add(new ListItem(没有产品信息,请添加."));
}这对您会有所帮助.
Hi Check this code.. oXMLNodeList = oXMLDoc.GetElementsByTagName("ProductDesc");
if ((oXMLDoc.ChildNodes.Count >= 1) && (oXMLNodeList.Count > 0))
{
DropDownList2.Items.Clear();
DropDownList2.Items.Add(new ListItem("-- Select Product Name --", "0"));
for (int intLoop = 0; intLoop <= oXMLNodeList.Count - 1; intLoop++)
{
strPlantId = oXMLDoc.GetElementsByTagName("ProductDesc").Item(intLoop).InnerText;
// strCategoryName = RXMLReservedChrConvert(oXMLDoc.GetElementsByTagName("Product_Name").Item(intLoop).InnerText);
DropDownList2.Items.Add(new ListItem(strPlantId));
}
}
else
{
DropDownList2.Items.Clear();
DropDownList2.Items.Add(new ListItem("No Product Information Exit, Please add."));
}this will be helpfull for you..
Drp.DataTextField = "groupname ";
Drp.DataValueField = "groupno";
Drp.DataBind();
Drp.Items.Insert(0,new ListItem("All", "----select------"));
这篇关于如何将带有文本的值从表绑定到asp.net中的dropdownlist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文