By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,929 Members | 634 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,929 IT Pros & Developers. It's quick & easy.

insert textBox values into database

parshupooja
100+
P: 159
Hello

I am trying to create to a Timesheet . I am intiating number of textboxes and label based on criteria chosen by admin. This is what i have written in pageload to generate timesheet for 2 weeks
Expand|Select|Wrap|Line Numbers
  1. for (int i = 1; i <= 14; i++)
  2.         {
  3.             Label date = new Label();
  4.             date.ID = "Item" + i.ToString();
  5.             date.Text = DateTime.Now.AddDays(i).ToShortDateString();
  6.             Label day = new Label();
  7.             day.ID = "day" + i.ToString();
  8.             day.Text = DateTime.Parse(date.Text).DayOfWeek.ToString();
  9.             day.Text = day.Text.Substring(0, 3);
  10.             TextBox txtmin = new TextBox();
  11.             txtmin.ID = "txtmin" + i.ToString();
  12.             TextBox txtmout = new TextBox();
  13.             TextBox txtain = new TextBox();
  14.             TextBox txtaout = new TextBox();
  15.             AreaDay.Controls.Add(day);
  16.             AreaDay.Controls.Add(new LiteralControl("<br><br><br>"));
  17.             AreaDate.Controls.Add(date);
  18.             AreaDate.Controls.Add(new LiteralControl("<br><br><br>"));
  19.             AreaMIn.Controls.Add(txtmin);
  20.             AreaMIn.Controls.Add(new LiteralControl(" <br> "));
  21.             AreaMOut.Controls.Add(txtmout);
  22.             AreaMOut.Controls.Add(new LiteralControl(" <br>  "));
  23.             AreaAIn.Controls.Add(txtain);
  24.             AreaAIn.Controls.Add(new LiteralControl("  <br> "));
  25.             AreaAOut.Controls.Add(txtaout);
  26.             AreaAOut.Controls.Add(new LiteralControl("  <br> "));
  27.         }
everything starts with Area is placeholders on page which I am using to to add controls

now on the click event of button i want to execute store procedure which passes these textboxes and label values to database.
Sep 6 '07 #1
Share this Question
Share on Google+
5 Replies


P: 13
Hello

I am trying to create to a Timesheet . I am intiating number of textboxes and label based on criteria chosen by admin. This is what i have written in pageload to generate timesheet for 2 weeks
...
everything starts with Area is placeholders on page which I am using to to add controls

now on the click event of button i want to execute store procedure which passes these textboxes and label values to database.
Are you asking how to get the information entered in the text boxes into a database? If so, it can depend on what developing environment you are using and what database you choose to use. What environment/compiler are you using and what type of database?
Sep 6 '07 #2

P: 2
Add all the controls created to a panel. Later loop through the control collection of panel and based on the id(i value) , insert the entries into the database.
Sep 6 '07 #3

parshupooja
100+
P: 159
@KBTibbs

Sorry forgot to mention I am using Asp.Net C#

Are you asking how to get the information entered in the text boxes into a database? If so, it can depend on what developing environment you are using and what database you choose to use. What environment/compiler are you using and what type of database?
Sep 7 '07 #4

parshupooja
100+
P: 159
@csoftee

You are right I thought of it but don't know how to achieve that. I am newbie . If u could show me snippet or lead me to example or article, that will be great help.

Thank You

Add all the controls created to a panel. Later loop through the control collection of panel and based on the id(i value) , insert the entries into the database.
Sep 7 '07 #5

P: 2
@csoftee

You are right I thought of it but don't know how to achieve that. I am newbie . If u could show me snippet or lead me to example or article, that will be great help.

Thank You
Looping can be done, but for creating timesheet these many controls are not needed, since passing on these many values to database constitutes redundant code. Try to create the timesheet in gridview which allows editing the entries. Sending the gridview data to database is easy as it will be bound to a datasource(ex:datatable, dataset). Check an example of a gridview and implement this.
Sep 7 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.