Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi,
Iam created dynamic txtbox,dropdownlist and button also.Now i want save those values in database.
Posted 13-Mar-12 18:47pm
Comments
Mantu Singh at 14-Mar-12 0:51am
   
please clarify more.....?
Hari Krishna Prasad Inakoti at 14-Mar-12 1:06am
   

Table table = new Table();
table.ID = "tbl_dy";
DropDownList ddl = new DropDownList();

Page.Form.Controls.Add(table);
if (!IsPostBack)
{
for (int i = 1; i < 3; i++)
{
TableRow row = new TableRow();
TableCell cell = new TableCell();
Label lbl = new Label();
lbl.ID = "lbl_'" + i + "'";
if (i == 1)
{
lbl.Text = "Name";
}
else { lbl.Text = "Salary"; }
cell.Controls.Add(new LiteralControl("  "));
TextBox txt = new TextBox();
txt.ID="txt_'"+i+"'";
cell.Controls.Add(new LiteralControl("<br/>"));
cell.Controls.Add(lbl);
cell.Controls.Add(txt);
row.Cells.Add(cell);
table.Rows.Add(row);
}
TableRow row1 = new TableRow();
TableCell cell1 = new TableCell();
Label lbl1 = new Label();
lbl1.ID = "lbl_gender";
lbl1.Text = "Gender";

ddl.Width = 180;
ddl.Height = 25;
ddl.ID = "ddl_gender";
ddl.Items.Add("Select");
ddl.Items.Add("Male");
ddl.Items.Add("Female");
cell1.Controls.Add(lbl1);
cell1.Controls.Add(new LiteralControl("  "));
cell1.Controls.Add(ddl);
row1.Cells.Add(cell1);
table.Rows.Add(row1);
}
}
Nilesh Patil Kolhapur at 14-Mar-12 0:53am
   
hari give some code
Hari Krishna Prasad Inakoti at 14-Mar-12 1:06am
   

Table table = new Table();
table.ID = "tbl_dy";
DropDownList ddl = new DropDownList();

Page.Form.Controls.Add(table);
if (!IsPostBack)
{
for (int i = 1; i < 3; i++)
{
TableRow row = new TableRow();
TableCell cell = new TableCell();
Label lbl = new Label();
lbl.ID = "lbl_'" + i + "'";
if (i == 1)
{
lbl.Text = "Name";
}
else { lbl.Text = "Salary"; }
cell.Controls.Add(new LiteralControl("  "));
TextBox txt = new TextBox();
txt.ID="txt_'"+i+"'";
cell.Controls.Add(new LiteralControl("<br/>"));
cell.Controls.Add(lbl);
cell.Controls.Add(txt);
row.Cells.Add(cell);
table.Rows.Add(row);
}
TableRow row1 = new TableRow();
TableCell cell1 = new TableCell();
Label lbl1 = new Label();
lbl1.ID = "lbl_gender";
lbl1.Text = "Gender";

ddl.Width = 180;
ddl.Height = 25;
ddl.ID = "ddl_gender";
ddl.Items.Add("Select");
ddl.Items.Add("Male");
ddl.Items.Add("Female");
cell1.Controls.Add(lbl1);
cell1.Controls.Add(new LiteralControl("  "));
cell1.Controls.Add(ddl);
row1.Cells.Add(cell1);
table.Rows.Add(row1);
}
}
SAKryukov at 14-Mar-12 1:28am
   
Hari Krishna, please move your comments with code to the question itself, use "Improve question". This is because there you can format it using "pre" tags.
I also could make a special code sample, more compact, using only relevant detail, just to make the problem more clear.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

foreach(Control c in this.Controls)
{
Textbox tb = c as Textbox;
 
string val = tb.Text;
}
  Permalink  
Comments
SathyaRaju at 14-Oct-13 0:45am
   
how to find dynamic text position in c# windows application.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Check the Google link[^]. If you have already tried something, share some code; else try some links first.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 540
1 OriginalGriff 290
2 CPallini 240
3 BillWoodruff 155
4 ChauhanAjay 149
0 OriginalGriff 6,609
1 Sergey Alexandrovich Kryukov 6,240
2 CPallini 5,180
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 14 Mar 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100