DropDownList1.DataSource=ArrayList1;
DropDownList1.DataBind();
DropDownList1.DataBind();
解决方案 »
- asp.net gridview 手动绑定数据后再编辑的问题,在线等!!
- Objectdatasource+封装fomview中的控件值为model时,无法转换类型,如何当textbox值为""时,model中的属性也为null
- aspx代码直接产生该页面的html输出问题
- 同样的图片为什么有的能显示有的不能呢
- 流媒体不兼容问题
- 关于gridview整体编辑结合三维数组来实现的难题!!
- 求助!关于Parameter 问题! 各位大哥帮帮忙..
- 怎么在后台验证邮件格式?
- 一个关于datagrid的简单问题 谢谢
- 如何实现对treeview的二次递归
- 关于一个调试问题:试图运行项目时出错.....,详情请进!
- 这个数据是用什么加密的?如何解密?
<head>
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
if(!IsPostBack)
{
ArrayList myList = new ArrayList();
myList.Add ("Item 1");
myList.Add ("Item 2");
myList.Add ("Item 3");
myList.Add ("Item 4");
myList.Add ("Item 5");
DropDownList1.DataSource = myList;
DropDownList1.DataBind();
}
}
void Button_Click(Object sender, EventArgs e)
{
Label1.Text = "You selected " + DropDownList1.SelectedItem.Text + ".";
}
</script>
</head>
<body>
<form runat="server">
<h3>DropDownList Data Bind Example</h3>
Select an item from the list and click the submit button.
<p>
<asp:DropDownList id="DropDownList1"
runat="server"/>
<br><br>
<asp:Button id="Button1"
Text="Submit"
OnClick="Button_Click"
runat="server"/>
<br><br>
<asp:Label id="Label1"
runat="server"/>
</form>
</body>
</html>
myAL.Add("Hello");
myAL.Add("World");
myAL.Add("!");
DropDownList1.DataSource=myAL;
DropDownList1.DataBind();
public interface IDepartment
{
IList GetSuperDept();
}2、在业务层里调用借口
public class Department
{
//
// 在接口查找方法
//
public IList GetSuperDept()
{
IDepartment dept=KenWang.DALFactory.Department.Create();
return dept.GetSuperDept();
}
3、在工厂层里建立实例
public static KenWang.IDAL.IDepartment Create()
{
//
// path,classname
//
string path=ConfigurationSettings.AppSettings["WebDAL"];
string classname=path+".Department"; //建立Instance
return (KenWang.IDAL.IDepartment)Assembly.Load(path).CreateInstance(classname); }
4、数据层里的方法
public IList GetSuperDept()
{ IList GetSuperDept=new ArrayList();
SqlDataReader rdr=SqlBase.GetDataReaderByExecute(SqlBase.SqlConnectString,USP);
while (rdr.Read())
{
DepartmentInfo department=new DepartmentInfo(rdr.GetInt32(0),rdr.GetString(1));
GetSuperDept.Add(department);
}
return GetSuperDept;
}本来目的想得到sqldatareader这样Dropdownlist可以直接绑定
可是Ilist不支持datareader返回 只好用arraylist