我在ASPX 拉了一个table 把cell 的ID 设成 tcell1,
然后我建了一个dropDownList 的类private DropDownList CallDrop(DataTable dt, string text, string value)
{
DropDownList dropDownList = new DropDownList();
//dropDownList.AutoPostBack = true;
dropDownList.Style.Add("width", "150px");
ListItem item = new ListItem();
item.Text = "";
item.Value = "0";
dropDownList.Items.Add(item);
foreach (DataRow row in dt.Rows)
{
ListItem ditem = new ListItem();
ditem.Text = row[text].ToString();
ditem.Value = row[value].ToString();
dropDownList.Items.Add(ditem);
}
return dropDownList;
}
之后把DropDownList 装入cellsql = "Select * FROM DBO_AA";
dt = db.GetDataTable(sql);
tcell1.Controls.Add(this.CallDrop(dt, "area", "code"));请问我怎么去获取DropDownList 的值??
然后我建了一个dropDownList 的类private DropDownList CallDrop(DataTable dt, string text, string value)
{
DropDownList dropDownList = new DropDownList();
//dropDownList.AutoPostBack = true;
dropDownList.Style.Add("width", "150px");
ListItem item = new ListItem();
item.Text = "";
item.Value = "0";
dropDownList.Items.Add(item);
foreach (DataRow row in dt.Rows)
{
ListItem ditem = new ListItem();
ditem.Text = row[text].ToString();
ditem.Value = row[value].ToString();
dropDownList.Items.Add(ditem);
}
return dropDownList;
}
之后把DropDownList 装入cellsql = "Select * FROM DBO_AA";
dt = db.GetDataTable(sql);
tcell1.Controls.Add(this.CallDrop(dt, "area", "code"));请问我怎么去获取DropDownList 的值??
解决方案 »
- 有更简单的方法吗?
- C#中&与&&有什么区别
- 请高手讲解一下C#开发 com的过程!
- 怎么在一个aspx中取到另一个aspx中的ctrols
- 怎么VS2003上的例题在VS2005上通不过啊????????
- 在EXCEL.DLL下,怎么读取EXCEL的空值啊?
- 基础问题关于C#中的#是什么意思?
- 怎样用C#编写一个录音程序
- ==========在delphi中有一个CreateWnd,在c#中对应哪个?==================
- <%@ Import Namespace="System.Data.SQL"%>这里会出错,不知为何?
- 急!~~~~~~~~在线等
- 获得数据库中倒数第二条数据时报错
{
DropDownList dropDownList = new DropDownList();
dropDownList.ID = text;
//dropDownList.AutoPostBack = true;
dropDownList.Style.Add("width", "150px");
ListItem item = new ListItem();
item.Text = "";
item.Value = "0";
dropDownList.Items.Add(item);
foreach (DataRow row in dt.Rows)
{
ListItem ditem = new ListItem();
ditem.Text = row[text].ToString();
ditem.Value = row[value].ToString();
dropDownList.Items.Add(ditem);
}
return dropDownList;
}取值((DropDownList)this.FindControl(text)).Text //text为上面 text的取值结帖