Click here to Skip to main content
15,889,096 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: showing dialog box n locking background screen... Pin
Ravi Munde28-Dec-08 19:50
Ravi Munde28-Dec-08 19:50 
QuestionHow I redirect after session timeout? Pin
Ravi Munde28-Dec-08 0:36
Ravi Munde28-Dec-08 0:36 
AnswerRe: How I redirect after session timeout? Pin
Colin Angus Mackay28-Dec-08 7:12
Colin Angus Mackay28-Dec-08 7:12 
QuestionGridView Populating n making every field a button Pin
vaibhavbaweja27-Dec-08 22:30
vaibhavbaweja27-Dec-08 22:30 
AnswerRe: GridView Populating n making every field a button Pin
cmpemikail27-Dec-08 22:38
cmpemikail27-Dec-08 22:38 
AnswerRe: GridView Populating n making every field a button Pin
Abhijit Jana28-Dec-08 4:18
professionalAbhijit Jana28-Dec-08 4:18 
GeneralRe: GridView Populating n making every field a button Pin
vaibhavbaweja28-Dec-08 4:22
vaibhavbaweja28-Dec-08 4:22 
QuestionPlease Help its urgent!!!!!!!!!!!!!!!!!!!! Pin
savianand27-Dec-08 20:01
savianand27-Dec-08 20:01 
I want to know the code how to save data from dynamically created textboxes.
The code I have written is this in whch I have dynamically created label and textboxes in a html table.The data in the label is from a table

The code I have written so far is


public partial class _Default : System.Web.UI.Page
{
TableRow row;
TableCell cell;
Label label1;
TextBox text;
SqlConnection cnn = new SqlConnection("server=.;database=northwind;uid=sa;pwd=");

void loaddata()
{
SqlCommand cmd = new SqlCommand("select * from Categories", cnn);
SqlDataReader dr;
cnn.Open();
dr = cmd.ExecuteReader();
int i=1;
while (dr.Read())
{
row = new TableRow();

cell = new TableCell();
label1 = new Label();
label1.Text = dr["CategoryName"].ToString();
cell.Text = label1.Text;
row.Cells.Add(cell);

cell = new TableCell();
text = new TextBox();
text.ID = "text" + i;
cell.Controls.Add(text);
row.Cells.Add(cell);

Table1.Rows.Add(row);
i++;

}
cnn.Close();
dr.Close();
}

protected void Page_Load(object sender, EventArgs e)
{


if (!Page.IsPostBack)
{ //Initiate the counter of dynamically added controls
this.NumberOfControls = 0;
}
else
{
// //Controls must be repeatedly be created on postback
this.loaddata();
}

}


protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 1; i <= NumberOfControls; i++)
{
SqlCommand cmd = new SqlCommand("insert into DUTYDATE (DateofDuty) values(@DateofDuty)", cnn);
try
{
string name = "text" + i.ToString();
TextBox tb = Table1.FindControl(name) as TextBox;

cmd.Parameters.AddWithValue("@DateofDuty", tb.Text);
}
catch (Exception)
{


}
}
}

protected int NumberOfControls
{
get
{

return (int)ViewState["NumControls"];
}
set
{
ViewState["NumControls"] = value;
}
}
}

can anyone tell how do i save data whch the user enter at run time as this code is not running....................

Frown | :( Confused | :confused: Unsure | :~ Sigh | :sigh:
AnswerRe: Please Help its urgent!!!!!!!!!!!!!!!!!!!! Pin
Nishant Singh27-Dec-08 21:01
Nishant Singh27-Dec-08 21:01 
AnswerRe: Please Help its urgent!!!!!!!!!!!!!!!!!!!! Pin
Abhijit Jana28-Dec-08 3:50
professionalAbhijit Jana28-Dec-08 3:50 
AnswerRe: Please Help its urgent!!!!!!!!!!!!!!!!!!!! Pin
Christian Graus28-Dec-08 7:31
protectorChristian Graus28-Dec-08 7:31 
QuestionHello EveryOne Pin
naim khan27-Dec-08 18:36
naim khan27-Dec-08 18:36 
AnswerRe: Hello EveryOne Pin
cmpemikail27-Dec-08 21:11
cmpemikail27-Dec-08 21:11 
AnswerRe: Hello EveryOne Pin
Abhijit Jana28-Dec-08 4:03
professionalAbhijit Jana28-Dec-08 4:03 
QuestionPosting an html code to asp.net Pin
cmpemikail27-Dec-08 11:30
cmpemikail27-Dec-08 11:30 
AnswerRe: Posting an html code to asp.net Pin
Colin Angus Mackay27-Dec-08 14:28
Colin Angus Mackay27-Dec-08 14:28 
QuestionRunning method in frequent Intervals --Webservice Pin
SatyaVas27-Dec-08 7:08
SatyaVas27-Dec-08 7:08 
QuestionPayroll System Pin
monika_vasvani27-Dec-08 5:32
monika_vasvani27-Dec-08 5:32 
AnswerRe: Payroll System Pin
Aman Bhullar27-Dec-08 6:10
Aman Bhullar27-Dec-08 6:10 
QuestionI want to discuss about a web project.Can I? Pin
R111927-Dec-08 3:35
R111927-Dec-08 3:35 
GeneralRe: I want to discuss about a web project.Can I? Pin
Guffa27-Dec-08 4:01
Guffa27-Dec-08 4:01 
GeneralRe: I want to discuss about a web project.Can I? Pin
R111927-Dec-08 4:09
R111927-Dec-08 4:09 
GeneralRe: I want to discuss about a web project.Can I? Pin
R111927-Dec-08 4:12
R111927-Dec-08 4:12 
GeneralRe: I want to discuss about a web project.Can I? Pin
Guffa27-Dec-08 9:41
Guffa27-Dec-08 9:41 
Questionhow to administer the back end database tables without directly altering it using SQL commands. ideas are needed ? Pin
Rameez Raja27-Dec-08 1:47
Rameez Raja27-Dec-08 1:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.