单击列表视图时,我有一个rad列表视图项,我正在生成控件,如果单击RadTextBox,则生成文本框,如果单击RadComboBox,则生成ComboBox,依此类推,但是所有控件都在生成当我单击列表视图项一次。如何正确地一一添加。
注意:所有Rad控件均来自不同的cs文件。
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
RadListView1.DataSource = GetDatatable();
RadListView1.DataBind();
}
}
public DataTable GetDatatable()
{
DataTable dt = new DataTable();
dt.Columns.Add("Label");
dt.Rows.Add("RadTextBox");
dt.Rows.Add("RadComboBox");
dt.Rows.Add("RadTimePicker");
dt.Rows.Add("RadDateTimePicker");
dt.Rows.Add("RadDropDownList");
return dt;
}
protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
{
string commandText = e.Argument.ToString().Trim();
string[] splitdata = commandText.Split('&');
commandText = splitdata[0];
switch (splitdata[0])
{
case "FillControl":
DynamicControls dc = new DynamicControls();
TableCell tc = dc.Controlscreation("RadLabel", "", 1, 0, "TextBox:", "", 0);
TableCell tc1 = dc.Controlscreation("RadTextBox", "", 1, 1, "", "", 0);
TableCell tc2 = dc.Controlscreation("RadComboBox", "", 2, 1, "", "", 0);
TableRow tr = new TableRow();
tr.Cells.Add(tc); tr.Cells.Add(tc1);
tr.Cells.Add(tc2);
Table1.Rows.Add(tr);
break;
}
}enter code here