How to Insert Records into Database
Hi everyone
I have one row with 6 text boxes, I am creating this row dynamically on button click.
Now I wanted to insert the data which is entered into these text boxes into database.
user can create any no of rows.
here I am giving my code snippet to create no of rows dynamically.
so how to do this cn you any one suggest me plz.
protected void Button1_Click(object sender, EventArgs e)
{
numOfColumns = 6;
//Generate the Table based from the inputs
GenerateTable(numOfColumns);
}
private void GenerateTable(int colsCount)
{
ctr++;
// Now iterate through the table and add your controls
TableRow row = new TableRow();
row.ID = "row" + ctr;
for (int j = 1; j <= colsCount; j++)
{
TableCell cell2 = new TableCell();
TextBox tb = new TextBox();
if (j == 1)
{
tb.ID = "txtJan" + ctr;
}
else if (j == 2)
{
tb.ID = "txtFeb" + ctr;
}
else if (j == 3)
{
tb.ID = "txtMar" + ctr;
}
else if (j == 4)
{
tb.ID = "txtApr" + ctr;
}
else if (j == 5)
{
tb.ID = "txtMay" + ctr;
}
else if (j == 6)
{
tb.ID = "txtJun" + ctr;
}
tb.Width = 120;
// Add the control to the TableCell
cell2.Controls.Add(tb);
// Add the TableCell to the TableRow
row.Cells.Add(cell2);
}
table.Rows.Add(row);
}
Thanks in Advance
Satish Madugundu