为什么 点击Button会将 动态生成的DropDownList中不绑定的数据清空?
为什么 点击Button会将 动态生成的DropDownList中不绑定的数据清空?
for (int i = 0; i < temp; ++i)
{
this.NewTableRow(i);
}
protected void NewTableRow(int i)
{
TableRow tr = new TableRow();
TableCell tc;
TextBox tb;
Label td;
DropDownList tl;
int rowqty = i + 1;
tc = new TableCell();
td = new Label();
td.CssClass = "FieldStyle";
td.ID = "txtDel" + i;
td.Text = "" + rowqty;
tc.Controls.Add(td);
tr.Cells.Add(tc);
tc = new TableCell();
tb = new TextBox();
tb.CssClass = "FieldStyle";
tb.ID = "txtItemno" + i;
tb.Attributes.Add("ondblclick", "getItem('" + i + "');");
tb.Attributes.Add("onclick", "getSelect('txtItemno"+ i + "');");
tc.Controls.Add(tb);
tr.Cells.Add(tc);
tc = new TableCell();
tb = new TextBox();
tb.CssClass = "FieldStyle";
tb.TextMode = TextBoxMode.MultiLine;
tb.Rows = 2;
tb.ID = "txtDes" + i;
tb.Attributes.Add("onblur", "getfu('txtDes" + i + "');");
tc.Controls.Add(tb);
tr.Cells.Add(tc);
tc = new TableCell();
tb = new TextBox();
tb.CssClass = "FieldStyle";
tb.ID = "txtModel" + i;
tb.Attributes.Add("onblur", "getfu('txtModel" + i + "');");
tc.Controls.Add(tb);
tr.Cells.Add(tc);
tc = new TableCell();
tb = new TextBox();
tb.CssClass = "FieldStyle";
tb.ID = "txtQty" + i;
tb.Attributes.Add("onblur", "getsum('txtQty" + i + "');");
tb.Attributes.Add("onclick", "getSelect('txtQty" + i + "');");
tc.Controls.Add(tb);
tr.Cells.Add(tc);
tc = new TableCell();
tb = new TextBox();
tb.CssClass = "FieldStyle";
tb.ID = "txtUOM" + i;
tc.Controls.Add(tb);
tr.Cells.Add(tc);
tc = new TableCell();
tb = new TextBox();
tb.CssClass = "FieldStyle";
//tb.ReadOnly = true;
tb.ID = "txtDate" + i;
tb.Attributes.Add("onclick","SelectDate(this,'yyyy-MM-dd')");
tc.Controls.Add(tb);
tr.Cells.Add(tc);
tc = new TableCell();
tb = new TextBox();
tb.CssClass = "FieldStyle";
tb.ID = "txtUPrice" + i;
tb.Attributes.Add("onblur", "getsum('txtUprice" + i + "');");
tb.Attributes.Add("onclick", "getSelect('txtUprice" + i + "');");
tc.Controls.Add(tb);
tr.Cells.Add(tc);
tc = new TableCell();
tb = new TextBox();
tb.CssClass = "FieldStyle";
tb.ID = "txtAccount" + i;
tc.Controls.Add(tb);
tr.Cells.Add(tc);
tc = new TableCell();
tb = new TextBox();
tb.CssClass = "FieldStyle";
tb.ID = "txtQuote" + i;
tc.Controls.Add(tb);
tr.Cells.Add(tc);
/*tc = new TableCell();
tb = new TextBox();
tb.CssClass = "FieldStyle";
tb.ID = "txtBuyer" + i;
tb.ReadOnly();
tc.Controls.Add(tb);
tr.Cells.Add(tc);*/
tc = new TableCell();
tl = new DropDownList();
tl.CssClass = "FieldStyle";
tl.ID = "txtBuyer" + i;
// tl.Style.Add("height", "21px");
for (int j = 0; j < tBuyer.Length; j++)
{
if (tBuyer[j]=="" | tBuyer[j]==null)
break;
tl.Items.Add(new ListItem(tBuyer[j],tBuyer[j]));
}
tr.Cells.Add(tc);
tc.Controls.Add(tl);
//DropDownList("txtBuyer" + i).DataSource = tBuyer;
//DropDownList("txtBuyer" + i).DataBind();
// Enumerable.Range(1, 10).Select("txtBuyer" + i).ToList().ForEach(tl.Items.Add(i));
this.m_table.Rows.Add(tr);
}
protected void btnAddDetail_Click(object sender, EventArgs e)
{
this.NewTableRow(this.Num++);
Label1.Text = this.Num.ToString();
}
...全文
相关推荐
asp.net可输入DropDownList, 两种方式动态绑定数据
可设置DataValueField,DataTextField,绝对值得下载的资源,使用简单,个人作品。
AVEVA System Platform界面定制:从环境搭建到数据绑定实践
工业监控系统界面定制是数字化转型中的关键环节,涉及数据绑定、OPC UA通信、Historian集成等核心概念。理解界面与底层数据模型的关系,是定制高效HMI的基础。通过合理的布局管理和控件体系,结合XAML绑定与异步刷新机制,可以构建响应式且稳定的工业界面。本文从AVEVA System Platform的实际项目出发,讲解环境搭建、控件开发、数据源对接及上线排查技巧,帮助工程师掌握从零到一实现定制界面的完整路径。
C#中DropDownList动态生成的方法
主要介绍了C#中DropDownList动态生成的方法,实例分析了C#中DropDownList的使用技巧,非常具有实用价值,需要的朋友可以参考下
清空dropdownlist值方法
在.net 中点击清空按钮可以清空dropdownlist里面值得方法
ASP.NET中DropDownList下拉框列表控件绑定数据的4种方法
本文主要介绍了DropDownList控件4种绑定数据的基础用法,希望对大家能有所帮助。


