ASP.NET中的dropdwonlist [英] dropdwonlist in ASP.NET

查看:176
本文介绍了ASP.NET中的dropdwonlist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,





今天我的问题是,



有一个下拉列表填充数据表。

填充后,我必须通过查找项目名称得到并设置默认值...(比如查找项目是MCP我在下拉列表中填充的内容) 。根据默认值,我必须显示网格视图...所以这是我在我的任务中的条件..请帮助我

hi all,


Todays my question is,

There is a dropdownlist populate by datatable.
after populating, i have to get and set the default value by finding the item name...(like find the item is MCP what i populated in dropdown). based on the default value i have to show the grid view ... so this is my condition in my task .. pls help me out

推荐答案

这是您的解决方案



Here comes your solution

//datatable here is the collection of data from which u want to select MCP

for(int i=0;i<=datatable.Rows.Count-1;i++)
{

if(datatable.items[i].Text=="MCP")
{
dropDown1.selectedIndex=i;
break;
}
}







希望它能解决你的问题.... 。




Hope it solves your problem.....


你好leosang



你为什么使用项目名称而不是选择项目值?,记住有一点是什么我们的客户看到,远离我们看到的东西。



请看一下:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols。 dropdownlist.aspx [ ^ ]

寻找:

DataSourceID

DataTextField

DataValueField


使用它来播放网格视图:

Hello leosang

Why are you using the item name instead of Selected Item Value?, remember that one thing is what our clients see, far away from what we see.

please take a look at this:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.dropdownlist.aspx[^]
Look for:
DataSourceID
DataTextField
DataValueField

Use this to play with your grid view:
Dim ListItemVariable as ListItem = DropDownList1.Items.FindByValue("YourValue")







Dim ValueVariable as object
DropDownList1.SelectedValue = ValueVariable;





gridview参考:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview .aspx [ ^ ]



您可以使用单个gridview并更改数据源或多个网格视图,并随时显示/隐藏。



问候,



Reference for gridview:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx[^]

You could use a single gridview and change the data source or multiple gridviews and show/hide anytime you want.

Regards,


这篇关于ASP.NET中的dropdwonlist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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