How to ReCreate Dynamically generated webcontrols which has an On_click event - c#

Current scenario: Main DDL of Decimal datatype input selection generates a new DDL. Upon input selection from new DDL it generates two labels and two textboxes with + button.
Current Issue: If i click the + button the recently generated dynamic web controls are hiding. How to avoid the hiding of controls and generate them continuously on every + button click event
My C# Code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindDropDownLists();
}
else
{
if (!String.IsNullOrEmpty(DropDownList5.SelectedValue))
{
if (DropDownList5.SelectedValue == "decimal")
{
createdynamiccontrols_decimal();
}
}
}
}
protected void DropDownList5_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void createdynamiccontrols_decimal()
{
int i = DropDownList5.SelectedIndex;
++i;
TableRow row = new TableRow();
row.ID = "TableRow_" + i.ToString();
TableCell cell1 = new TableCell();
DropDownList Range_DDL_Decimal = new DropDownList();
Range_DDL_Decimal.ID = "RandeDDL_Decimal" + i.ToString();
Range_DDL_Decimal.Items.Insert(0, new ListItem("--Select--", "--Select--"));
Range_DDL_Decimal.Items.Insert(1, new ListItem("Equal", "Equal"));
Range_DDL_Decimal.Items.Insert(2, new ListItem("NotEqual", "NotEqual"));
Range_DDL_Decimal.Items.Insert(3, new ListItem("greater than", "greater than"));
Range_DDL_Decimal.Items.Insert(4, new ListItem("lesser than", "lesser than"));
Range_DDL_Decimal.Items.Insert(5, new ListItem("greater than or equal to", "greater than or equal to"));
Range_DDL_Decimal.Items.Insert(6, new ListItem("lesser than or equal to", "lesser than or equal to"));
Range_DDL_Decimal.Items.Insert(7, new ListItem("Contains", "Contains"));
Range_DDL_Decimal.Items.Insert(8, new ListItem("Is Null", "Is Null"));
Range_DDL_Decimal.Items.Insert(9, new ListItem("Is Not Null", "Is Not Null"));
Range_DDL_Decimal.Items.Insert(10, new ListItem("Between", "Between"));
Range_DDL_Decimal.AutoPostBack = true;
Range_DDL_Decimal.SelectedIndexChanged += new System.EventHandler(Range_DDL_Decimal_SelectedIndexChanged);
cell1.Controls.Add(Range_DDL_Decimal);
//// Add the TableCell to the TableRow
row.Cells.Add(cell1);
dynamic_filter_table.Rows.Add(row);
dynamic_filter_table.EnableViewState = true;
ViewState["dynamic_filter_table"] = true;
}
protected void Range_DDL_Decimal_SelectedIndexChanged(object sender, EventArgs e)
{
int j = DropDownList5.SelectedIndex;
++j;
TableRow rowtwo;
rowtwo = new TableRow();
TableCell cell1 = new TableCell();
TableCell cell2 = new TableCell();
TableCell cell3 = new TableCell();
TextBox tb1 = new TextBox();
TextBox tb2 = new TextBox();
Label lbl1 = new Label();
Label lbl2 = new Label();
// Set a unique ID for each TextBox added
tb1.ID = "lowerbound_" + j.ToString();
tb2.ID = "upperbound_" + j.ToString();
lbl1.Text = "LowerBound:";
lbl1.Font.Size = FontUnit.Point(10);
lbl1.Font.Bold = true;
lbl1.Font.Name = "Arial";
lbl2.Text = "UpperBound:";
lbl2.Font.Size = FontUnit.Point(10);
lbl2.Font.Bold = true;
lbl2.Font.Name = "Arial";
Button addmore = new Button();
addmore.ID = "Button_Decimal" + j.ToString();
addmore.Text = "+";
addmore.Click += new System.EventHandler(Addmore_click);
**//If this button is clicked the Dynamic controls are vanished**
cell1.Controls.Add(lbl1);
cell1.Controls.Add(tb1);
cell2.Controls.Add(lbl2);
cell2.Controls.Add(tb2);
cell3.Controls.Add(addmore);
rowtwo.Cells.Add(cell1);
rowtwo.Cells.Add(cell2);
rowtwo.Cells.Add(cell3);
dynamic_filter_table.Rows.Add(rowtwo);
dynamic_filter_table.EnableViewState = true;
ViewState["dynamic_filter_table"] = true;
}
protected void Addmore_click(object sender, EventArgs e)
{
**//Generate dynamic controls on every click of + button
//How to procced**
}
protected void Page_PreInit(object sender, EventArgs e)
{
}

There are not hiding, you have to recreate the dynamically created controls on every request.
It has been a while, but I think you have to create the dynamic controls in the Page_Init event for them to be included in the view-state.
Some sources

Related

Dynamic controls dissapearing on postback

I am creating dynamic textboxes when clicking on a set of different radio button. Below is an example of two radio button onclick event.
protected void Checkbox1_CheckedChanged(object sender, EventArgs e)
{
string servicename = "service1";
if (checkbox1.Checked)
{
InputParameters.InputParameters aa= new InputParameters.InputParameters();
textbox = aa.GetInputFields(servicename);
for (int i=0;i<textbox.Count;i++)
{
// declare a textbox
TextBox CPDT = new TextBox();
CPDT.ID = servicename + i.ToString();
CPDT.CssClass = "form-control";
CPDT.EnableViewState = true;
Label lblCPD=new Label();
lblCPD.ID = "txtDynamiclbl" + servicename+ i.ToString();
lblCPD.CssClass= "form-control-label";
lblCPD.Text= textbox[i].ToString();
lblCPD.EnableViewState = true;
CPDPlaceHolder.Controls.Add(lblCPD);
CPDPlaceHolder.Controls.Add(CPDT);
//this.NumberOfControls++;
}
Button callSoap = new Button();
callSoap.ID = "txtDynamicSearch" + servicename;
callSoap.Text = "Search";
callSoap.CssClass = ".btn-info";
callSoap.CommandArgument = "test";
callSoap.Click += new EventHandler(btnsoap);
callSoap.EnableViewState = true;
CPDPlaceHolder.Controls.Add(callSoap);
}
else
{
}
}
protected void Checkbox2_CheckedChanged(object sender, EventArgs e)
{
string servicename = "service2";
if (checkbox2.Checked)
{
InputParameters.InputParameters aa = new InputParameters.InputParameters();
List<String> textbox = aa.GetInputFields("test1");
// textboxs.AddRange(textbox);
for (int i = 0; i < textbox.Count; i++)
{
// declare a textbox
TextBox CPDT = new TextBox();
CPDT.ID = servicename + i.ToString();
CPDT.CssClass = "form-control";
Label lblCPD = new Label();
lblCPD.ID = "txtDynamiclbl" + servicename + i.ToString();
lblCPD.CssClass = "form-control-label";
lblCPD.Text = textbox[i].ToString();
CPDPlaceHolder.Controls.Add(lblCPD);
CPDPlaceHolder.Controls.Add(CPDT);
}
Button callSoap = new Button();
callSoap.ID = "txtDynamicSearch" + servicename;
callSoap.Text = "Search";
callSoap.CssClass = ".btn-info";
callSoap.CommandArgument = "test1";
callSoap.Click += new EventHandler(btnsoap);
callSoap.EnableViewState = true;
CPDPlaceHolder.Controls.Add(callSoap);
}
else
{
}
}
The textboxes and search button appears as needed. The problem now is when i clicked on the search button a post back occur and all the controls are gone. I have been reading a lot about initialising the controls in page_preinit and i tried the code below.
protected void Page_PreInit(object sender, EventArgs e)
{
List<string> keys = Request.Form.AllKeys.Where(key => key.Contains("txtDynamic")).ToList();
int i = 1;
try
{
foreach (string key in keys)
{
TextBox CPDT = new TextBox();
CPDT.ID = "test" + i.ToString();
CPDT.CssClass = "form-control";
Label lblCPD = new Label();
lblCPD.ID = "txtDynamiclbl" + "test" + i.ToString();
lblCPD.CssClass = "form-control-label";
lblCPD.Text = textbox[i].ToString();
CPDPlaceHolder.Controls.Add(lblCPD);
CPDPlaceHolder.Controls.Add(CPDT);
i++;
}
}
catch
{
}
}
In the above function this line only returns the search button and not the texboxes. I am stuck on this issue.
List<string> keys = Request.Form.AllKeys.Where(key => key.Contains("txtDynamic")).ToList();
T

Dynamically created and displayed jagged array of Textboxes loses its state after event handler is called.

I am trying to create a form for courses provided by a University. Based on the no of subjects obtained through a query string, a form gets generated. If the subject has electives, the user has to check a checkbox, which further generates a no of textboxes for subject names. But whenever I check the checkbox of say 2nd subject the textboxes previously displayed for 1st subject disappear.
ASP CODE
<html>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
C# code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Demo : System.Web.UI.Page
{
#region variables
Label[] lb_subject_names;
TextBox[] tb_subject_names;
Label[] lb_elective;
Table[] table_electives;
CheckBox[] cb_elective;
TextBox[] tb_no_of_elective;
Button[] bt_electives_ok;
TextBox[][] tb_name_of_electives;
TextBox[][] tb_code_of_electives;
#endregion
protected void Page_Load(object sender, EventArgs e)
{
int no_subjects = 3;// int.Parse(Request.QueryString["NoSubjects"]);
//declare
lb_subject_names = new Label[no_subjects];
tb_subject_names = new TextBox[no_subjects];
lb_elective = new Label[no_subjects];
table_electives = new Table[no_subjects];
cb_elective = new CheckBox[no_subjects];
tb_no_of_elective = new TextBox[no_subjects];
bt_electives_ok = new Button[no_subjects];
tb_name_of_electives = new TextBox[no_subjects][];
tb_code_of_electives = new TextBox[no_subjects][];
//initialize
for (int i = 0; i < no_subjects; i++)
{
lb_subject_names[i] = new Label();
tb_subject_names[i] = new TextBox();
lb_elective[i] = new Label();
table_electives[i] = new Table();
table_electives[i].BorderStyle = BorderStyle.Solid;
tb_no_of_elective[i] = new TextBox();
cb_elective[i] = new CheckBox();
cb_elective[i].AutoPostBack = true;
cb_elective[i].ID = (i).ToString();
cb_elective[i].CheckedChanged += new EventHandler(cb_elective_CheckedChanged);
bt_electives_ok[i] = new Button();
bt_electives_ok[i].Text = "OK";
bt_electives_ok[i].ID = "bt_" + (i).ToString();
bt_electives_ok[i].Click += new EventHandler(bt_electives_ok_clicked);
}
//display in form1
for (int i = 0; i < no_subjects; i++)
{
lb_subject_names[i].Text = "<br/>Subject Name : ";
form1.Controls.Add(lb_subject_names[i]);
form1.Controls.Add(tb_subject_names[i]);
lb_elective[i].Text = "Does the Subject provide Electives ?";
form1.Controls.Add(lb_elective[i]);
form1.Controls.Add(cb_elective[i]);
tb_no_of_elective[i].Visible = false;
bt_electives_ok[i].Visible = false;
form1.Controls.Add(tb_no_of_elective[i]);
form1.Controls.Add(bt_electives_ok[i]);
form1.Controls.Add(table_electives[i]);
}
}
protected void cb_elective_CheckedChanged(object sender, EventArgs e)
{
CheckBox currentCheckbox = sender as CheckBox;
int id = int.Parse(currentCheckbox.ID);
if (currentCheckbox != null && currentCheckbox.Checked)
{
tb_no_of_elective[id].Visible = true;
bt_electives_ok[id].Visible = true;
table_electives[id].Visible = true;
}
else
{
tb_no_of_elective[id].Visible = false;
bt_electives_ok[id].Visible = false;
table_electives[id].Visible = false;
}
}
protected void bt_electives_ok_clicked(object sender, EventArgs e)
{
Button button = sender as Button;
String str_id = button.ID;
int id = int.Parse(str_id.Substring(3, str_id.Length - 3));
int no_of_electives = int.Parse(tb_no_of_elective[id].Text);
tb_name_of_electives[id] = new TextBox[no_of_electives];
tb_code_of_electives[id] = new TextBox[no_of_electives];
for (int i = 0; i < no_of_electives; i++)
{
tb_name_of_electives[id][i] = new TextBox();
tb_code_of_electives[id][i] = new TextBox();
}
//row1 header
TableRow e_row1 = new TableRow();
TableCell e_cell1_1 = new TableCell();
e_cell1_1.Text = "Sr. No.";
e_row1.Controls.Add(e_cell1_1);
TableCell e_cell1_2 = new TableCell();
e_cell1_2.Text = "Subject Code";
e_row1.Controls.Add(e_cell1_2);
TableCell e_cell1_3 = new TableCell();
e_cell1_3.Text = "Subject Name";
e_row1.Controls.Add(e_cell1_3);
table_electives[id].Controls.Add(e_row1);
for (int i = 0; i < no_of_electives; i++)
{
//row2
TableRow e_row2 = new TableRow();
TableCell e_cell2_1 = new TableCell();
e_cell2_1.Text = (i + 1).ToString();
e_row2.Controls.Add(e_cell2_1);
TableCell e_cell2_2 = new TableCell();
e_cell2_2.Controls.Add(tb_code_of_electives[id][i]);
e_row2.Controls.Add(e_cell2_2);
TableCell e_cell2_3 = new TableCell();
e_cell2_3.Controls.Add(tb_name_of_electives[id][i]);
e_row2.Controls.Add(e_cell2_3);
table_electives[id].Controls.Add(e_row2);
}
}
}

Button Click event not firing for dynamically created button

I have created dynamic controls on DropdownList's SelectedIndexChanged event. Button is one of those controls. I have also assigned event to that button but debugger is not coming on that click event. Following is my code.
protected void Page_Load(object sender, EventArgs e)
{
try
{
token = Session["LoginToken"].ToString();
if (!IsPostBack)
{
BindData();
fsSearch.Visible = false;
btnDownload.Visible = false;
}
else
{
foreach (HtmlTableRow row in (HtmlTableRowCollection)Session["dynamicControls"])
{
tblSearch.Rows.Add(row);
}
}
}
catch
{
}
}
private void BindData()
{
ddlReportName.DataSource = svcCommon.GetReports(token, out message);
ddlReportName.DataValueField = "Key";
ddlReportName.DataTextField = "Value";
ddlReportName.DataBind();
ddlReportName.Items.Insert(0, "--Select--");
}
protected void ddlReportName_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
string[] reportInfo = ddlReportName.SelectedValue.Split('|');
Session["dynamicControls"] = null;
tblSearch.Rows.Clear();
HtmlTableRow row = new HtmlTableRow();
HtmlTableCell cellFieldNameLbl = new HtmlTableCell();
HtmlTableCell cellFieldNameDdl = new HtmlTableCell();
HtmlTableCell cellOperatorLbl = new HtmlTableCell();
HtmlTableCell cellOperatorDdl = new HtmlTableCell();
HtmlTableCell cellValueLbl = new HtmlTableCell();
HtmlTableCell cellValueTxt = new HtmlTableCell();
HtmlTableCell cellOperatorRbtn = new HtmlTableCell();
HtmlTableCell cellAddMoreFilter = new HtmlTableCell();
Button btnAddMore = new Button();
DropDownList ddlColumn = new DropDownList();
DropDownList ddlOperator = new DropDownList();
TextBox txtValue = new TextBox();
RadioButtonList rbtnOperator = new RadioButtonList();
List<string> filterValues = svcCommon.GetSearchColumns(Convert.ToInt64(reportInfo[0]), token, out message);
fsSearch.Visible = btnDownload.Visible = filterValues.Count > 0 ? true : false;
ddlColumn.ID = "_ddlColumn0";
ddlOperator.ID = "_ddlOperator0";
txtValue.ID = "_txtValue0";
rbtnOperator.ID = "_rbtnOperator0";
btnAddMore.ID = "_btnAddMore0";
rbtnOperator.Items.Add("AND");
rbtnOperator.Items.Add("OR");
rbtnOperator.RepeatDirection = RepeatDirection.Horizontal;
btnAddMore.Text = "Add More";
btnAddMore.Click +=btnAddMore_Click;
ddlColumn.DataSource = filterValues;
ddlColumn.DataBind();
ddlOperator.DataSource = new List<string>()
{
"Equal",
"Not Equal",
"Less Than",
"Less Than Or Equal",
"Greater Than",
"Greater Than Or Equal",
"Start With",
"Not Start With",
"End With",
"Not End With",
"Contains",
"Not Contains",
"Between",
"Not Between",
"In",
"Not In"
};
ddlOperator.DataBind();
cellFieldNameLbl.InnerText = "Field Name:";
cellFieldNameDdl.Controls.Add(ddlColumn);
cellOperatorLbl.InnerText = "Operator";
cellOperatorDdl.Controls.Add(ddlOperator);
cellValueLbl.InnerText = "Value";
cellValueTxt.Controls.Add(txtValue);
cellOperatorRbtn.Controls.Add(rbtnOperator);
cellAddMoreFilter.Controls.Add(btnAddMore);
row.Cells.Add(cellFieldNameLbl);
row.Cells.Add(cellFieldNameDdl);
row.Cells.Add(cellOperatorLbl);
row.Cells.Add(cellOperatorDdl);
row.Cells.Add(cellValueLbl);
row.Cells.Add(cellValueTxt);
row.Cells.Add(cellOperatorRbtn);
row.Cells.Add(cellAddMoreFilter);
tblSearch.Rows.Add(row);
Session["dynamicControls"] = tblSearch.Rows;
}
catch (Exception ex)
{
}
}
protected void btnAddMore_Click(object sender, EventArgs e)
{
try
{
}
catch
{
}
}
The problem with dynamically created controls in asp.net webforms is that they aren't automatically added to the viewstate, so the postback event won't happen.
This should help you to understand adding controls dynamically, and managing them via the viewstate http://forums.asp.net/t/1900207.aspx?Creating+buttons+dynamically
Alternatively, a much easier way to manage this is to have the buttons on the page but not visible, then in the selected_index_changed event, just switch the visibility to true.
I hadn't enough time to try so many thing. The thing I did is stored the container on which dynamic controls are added into Session and on Page_Init event I have bound event and it is working fine now. :)

Not able to store information while postback after creating dynamic dropdown in ASP.NET

here is my code
after button 2 click event it is creating the dropdown in table rows but when I try to save by button 1 click event it just disappear. I have not find any solution regarding this. I have used find control view State etc but it's not helping.
I want to store selected values of dropdown after button_1 click event starts.
public partial class StudentClassSectionMapping : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
ClassCode.Enabled = false;
}
}
protected void Button2_Click(object sender, EventArgs e)
{
UpdateModalShowFlag.Value = "true";
Check.Value = "true";
CreateTableRows();
}
private void CreateTableRows()
{
long h = long.Parse(LinkButtonIdCarrier.Value);
List<StudentsClassSectionMapping.StudentsClassSectionMappingForm> allStudentsInClass = StudentsClassSectionMapping.GetStudentsinClass(h);
ClassMaster.ClassMasterForm classCode = Schoolclasses.GetInfo(h);
ClassCode.Text = classCode.cCode;
List<StudentsClassSectionMapping.StudentsClassSectionMappingForm> allSectionsInClass = StudentsClassSectionMapping.GetSectionsinClass(h);
foreach (StudentsClassSectionMapping.StudentsClassSectionMappingForm studentList in allStudentsInClass)
{
TableRow row = new TableRow();
TableCell cell1 = new TableCell();
TableCell cell2 = new TableCell();
TableCell cell3 = new TableCell();
DropDownList t = new DropDownList();
t.Items.Add("No Section");
foreach (StudentsClassSectionMapping.StudentsClassSectionMappingForm sectionList in allSectionsInClass)
{
t.Items.Add(sectionList.ssSection);
t.Items[t.Items.Count - 1].Value = sectionList.ssSectionID.ToString();
}
t.Attributes.Add("class", "form-control");
t.ID = studentList.ssStudentId.ToString();
cell1.Text = studentList.ssName;
cell2.Text = studentList.ssRegistrationNumber;
cell3.Controls.Add(t);
row.Cells.Add(cell1);
row.Cells.Add(cell2);
row.Cells.Add(cell3);
Table1.Rows.Add(row);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
CreateTableRows();
long h = long.Parse(LinkButtonIdCarrier.Value);
List<StudentsClassSectionMapping.StudentsClassSectionMappingForm> allStudentsInClass = StudentsClassSectionMapping.GetStudentsinClass(h);
foreach (StudentsClassSectionMapping.StudentsClassSectionMappingForm studentList in allStudentsInClass)
{
DropDownList d = Table1.FindControl(studentList.ssStudentId.ToString()) as DropDownList;
if (d != null)
{
if (d.SelectedIndex != 0)
{
StudentsClassSectionMapping.StudentsClassSectionMappingForm studentSectionMapping = new StudentsClassSectionMapping.StudentsClassSectionMappingForm();
studentSectionMapping.ssClassId = h;
studentSectionMapping.ssStudentId = studentList.ssStudentId;
studentSectionMapping.ssStudentId = long.Parse(d.SelectedItem.Value);
StudentsClassSectionMapping.addSectionStudentMapping(studentSectionMapping);
}
else
{
StudentsClassSectionMapping.StudentsClassSectionMappingForm studentSectionMapping = new StudentsClassSectionMapping.StudentsClassSectionMappingForm();
studentSectionMapping.ssClassId = h;
studentSectionMapping.ssStudentId = 0;
studentSectionMapping.ssStudentId = 0;
StudentsClassSectionMapping.addSectionStudentMapping(studentSectionMapping);
}
}
}
}
It get vanished/disappear because you added it dynamically on page. If you want it back or want to reserver control which is dynamically created you need to recreate again and need to add dynamically.
Here is good example of how you can do it : How to create controls dynamically in ASP.NET and retrieve values from it

sending data to event handler when the event is called programmatically

protected void Page_Load(object sender, EventArgs e)
{
Team T = new Team();
string[] TLeaders = T.GetAllTeamLeaders(Session["USER_EMAIL"].ToString(), Session["ProjectID"].ToString());
for (int i = 0; i < TLeaders.Length; i++)
{
System.Web.UI.HtmlControls.HtmlGenericControl createDiv =new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
createDiv.Style.Add(HtmlTextWriterStyle.BorderStyle, "Solid");
createDiv.Style.Add(HtmlTextWriterStyle.BorderColor, "lightblue");
createDiv.Style.Add(HtmlTextWriterStyle.BorderWidth, "1px");
createDiv.Style.Add(HtmlTextWriterStyle.Height, "100px");
createDiv.Style.Add(HtmlTextWriterStyle.Width, "1350px");
createDiv.Style.Add(HtmlTextWriterStyle.MarginTop, "20px");
createDiv.Style.Add(HtmlTextWriterStyle.BackgroundColor, "white");
DivRate.Controls.Add(createDiv);
Label LeaderName = new Label();
LeaderName.Text = TLeaders[i];
LeaderName.Style.Add("margin-left", "600px");
LeaderName.Style.Add("color","gray");
LeaderName.Style.Add("font-size","20px;");
LeaderName.Style.Add("margin-top", "10px");
LeaderName.Style.Add("position", "absolute");
createDiv.Controls.Add(LeaderName);
RadioButtonList Rate = new RadioButtonList();
ListItem bad = new ListItem();
ListItem fair = new ListItem();
ListItem good= new ListItem();
ListItem veryGood = new ListItem();
ListItem excellent = new ListItem();
bad.Value = "1";
bad.Text = "Bad";
fair.Value = "2";
fair.Text = "Fair";
good.Value = "3";
good.Text = "Good";
veryGood.Value = "4";
veryGood.Text = "Very Good";
excellent.Value = "5";
excellent.Text = "Excellent";
Rate.AutoPostBack = true;
Rate.Items.Add(bad);
Rate.Items.Add(fair);
Rate.Items.Add(good);
Rate.Items.Add(veryGood);
Rate.Items.Add(excellent);
Rate.Attributes.Add("onchange", "return LeaderName('"+TLeaders[i]+"');");
Rate.SelectedIndexChanged += new EventHandler(CheckChange("s"));
Rate.RepeatColumns=5;
Rate.Width = 10;
Rate.Height = 10;
Rate.CssClass = "RateClass";
createDiv.Controls.Add(Rate);
}
}
so in this code I create a div and I place inside it a label and a Radio Button List however what i want to do is to create an event handler and send a data to it when i call it i call it like this:
Rate.SelectedIndexChanged += new EventHandler(CheckChange("s"));
and this is the event handler:
protected void CheckChange(string s)
{
ScriptManager.RegisterStartupScript(Page, typeof(Page), "", "fun('" + s + "')", true);
}
It give me an error "method name expected" when I send the data like this
any solution?

Categories