TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
satish kumar
NA
10
63.1k
How to Insert Records into Database
Aug 25 2011 2:00 AM
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
Reply
Answers (
1
)
How to send an email?
Orchard CMS table query