PLZ RESOLVE THIS EXCEPTION ITS URGENT
PLZ RESOLVE THIS EXCEPTION ITS URGENT
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
akash singhPosted Dec 27, 2014, 12:43 AM
akash singhPosted Dec 27, 2014, 12:42 AM
Manish Kumar ChoudharyPosted Dec 26, 2014, 7:46 AM
lbl.Text+= txt.ID
akash singhPosted Dec 26, 2014, 5:47 AM
akash singhPosted Dec 26, 2014, 5:47 AM
akash singhPosted Dec 26, 2014, 2:20 AM
akash singhPosted Dec 26, 2014, 2:20 AM
Manish Kumar ChoudharyPosted Dec 26, 2014, 1:53 AM
Hi akash singh,
Use likes this in button click
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < ListBox2.GetSelectedIndices().Count();i++ )
{
if ((TextBox)Panle1.FindControl("txt"+ListBox2.SelectedIndex) != null)
{
TextBox txt = (TextBox)Panle1.FindControl("txt" + ListBox2.SelectedIndex);
Response.Write("TextBox ID = " + txt.ID + "
");
Response.Write("TextBox Text = " + txt.Text + "
");
}
else
Response.Write("Nothing is there");
}
And create a method
void AddControl()
{
if (ListBox2.SelectedIndex != -1)
{
Table tbl = new Table();
tbl.ID = "Tabl";
tbl.EnableViewState = true;
tbl.ViewStateMode = ViewStateMode.Enabled;
// tbl.Attributes.Add("runat", "server");
for (int i = 0; i < ListBox2.Items.Count; i++)
{
//TableRow tr = new TableRow();
if (ListBox2.Items[i].Selected)
{
//++ind;
TableRow tr = new TableRow();
tr.EnableViewState = true;
tr.ViewStateMode = ViewStateMode.Enabled;
// tr.Attributes.Add("runat", "server");
TableCell col = new TableCell();
col.EnableViewState = true;
col.ViewStateMode = ViewStateMode.Enabled;
// col.Attributes.Add("runat", "server");
col.Width = 100;
Label Lbl = new Label();
Lbl.Text = ListBox2.Items[i].Text;
Lbl.ID = "lbl" + i.ToString();
Lbl.ForeColor = System.Drawing.Color.Red;
col.Controls.Add(Lbl);
// arr[ind] = Lbl.Text;
TableCell col1 = new TableCell();
TextBox txt = new TextBox();
txt.ID = "txt" + i.ToString();
txt.EnableViewState = true;
txt.ViewStateMode = ViewStateMode.Enabled;
// txt.ID = ListBox2.Items[i].Text;
txt.Width = 150;
txt.Height = 20;
col1.Controls.Add(txt);
tr.Cells.Add(col);
tr.Cells.Add(col1);
//Lbl1.Text = "txt" + i.ToString();
// txt.TextChanged += new EventHandler(adddff);
// LabCHK.Text += tr.Cells[2];
// tbl.Rows.Add(tr);
tbl.Rows.Add(tr);
}
}
Panle1.Controls.Add(tbl);
}
}
and call it in page lode in place of ListBox Selected Index change
protected void Page_Load(object sender, EventArgs e)
{
AddControl();
}