Click here to Skip to main content
15,914,016 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionFetching value from textbox dyanamically Pin
ashutosh_karna14-Jul-09 8:27
ashutosh_karna14-Jul-09 8:27 
I have a web form with a table control. No. of columns & no. of rows are asked by user and table is generated with cells filled with textboxes dynamically. The id of textboxes are generated dynamically. User enters the values in textboxes in table & click calculate button, on which I want to supply a set of results based on input data. Can anybody tell me how to fetch the value entered in a textbox at runtime. I am using following code.

public void CreateTableRawData(int rows)
{


for (int i = 0; i < rows; i++)
{
TableRow tr = new TableRow();
TableCell td = new TableCell();

TextBox txt = new TextBox();
td.Controls.Add(txt);
txt.ID = "txt" + i.ToString();

tr.Cells.Add(td);

Table1.Rows.Add(tr);
Table1.Caption = "Raw Data Form";
}

}

protected void Button2_Click(object sender, EventArgs e)
{

int rows = Convert.ToInt32(TextBox_rows.Text.ToString());
double[] data = new double[rows];
string [] dataText = new string[rows];
Table tbl = (Table)Panel1.FindControl("Table1");
for (int i = 0; i < rows; i++)
{
data[i] = Convert.ToDouble(Table1.Rows[i].Cells[0].Text.ToString());

}

data[0] = Convert.ToDouble(Table1.Rows[0].Cells[0].ToString());
Label lbl = new Label();
double sum = DistributionFitting.Statistics.Sum(data);
lbl.Text = sum.ToString();

}

I am getting following error at runtime.
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
AnswerRe: Fetching value from textbox dyanamically Pin
Brij14-Jul-09 8:35
mentorBrij14-Jul-09 8:35 
AnswerRe: Fetching value from textbox dyanamically Pin
Abhijit Jana14-Jul-09 8:41
professionalAbhijit Jana14-Jul-09 8:41 
QuestionApplying different themes to same page or Applying different styles to same page Pin
jophinmichael14-Jul-09 6:26
jophinmichael14-Jul-09 6:26 
AnswerRe: Applying different themes to same page or Applying different styles to same page Pin
Abhijit Jana14-Jul-09 7:20
professionalAbhijit Jana14-Jul-09 7:20 
GeneralRe: Applying different themes to same page or Applying different styles to same page Pin
jophinmichael14-Jul-09 7:45
jophinmichael14-Jul-09 7:45 
AnswerRe: Applying different themes to same page or Applying different styles to same page Pin
Brij14-Jul-09 7:32
mentorBrij14-Jul-09 7:32 
GeneralRe: Applying different themes to same page or Applying different styles to same page Pin
jophinmichael14-Jul-09 9:13
jophinmichael14-Jul-09 9:13 
AnswerRe: Applying different themes to same page or Applying different styles to same page Pin
Abhijit Jana14-Jul-09 9:22
professionalAbhijit Jana14-Jul-09 9:22 
GeneralRe: Applying different themes to same page or Applying different styles to same page Pin
jophinmichael18-Jul-09 5:04
jophinmichael18-Jul-09 5:04 
GeneralRe: Applying different themes to same page or Applying different styles to same page Pin
Brij14-Jul-09 9:33
mentorBrij14-Jul-09 9:33 
QuestionIframe source , Are cookies playing a role in this case? Pin
vjvjvjvj14-Jul-09 5:50
vjvjvjvj14-Jul-09 5:50 
AnswerRe: Iframe source , Are cookies playing a role in this case? Pin
Kannan Ar14-Jul-09 6:05
professionalKannan Ar14-Jul-09 6:05 
AnswerRe: Iframe source , Are cookies playing a role in this case? Pin
DoctorMick14-Jul-09 6:17
DoctorMick14-Jul-09 6:17 
GeneralRe: Iframe source , Are cookies playing a role in this case? Pin
vjvjvjvj14-Jul-09 6:59
vjvjvjvj14-Jul-09 6:59 
GeneralListbox Control giving NULL reference exception Pin
PDTUM14-Jul-09 5:39
PDTUM14-Jul-09 5:39 
GeneralRe: Listbox Control giving NULL reference exception Pin
Kannan Ar14-Jul-09 5:58
professionalKannan Ar14-Jul-09 5:58 
GeneralRe: Listbox Control giving NULL reference exception Pin
PDTUM14-Jul-09 6:08
PDTUM14-Jul-09 6:08 
GeneralRe: Listbox Control giving NULL reference exception Pin
Kannan Ar14-Jul-09 6:14
professionalKannan Ar14-Jul-09 6:14 
GeneralRe: Listbox Control giving NULL reference exception Pin
DoctorMick14-Jul-09 6:19
DoctorMick14-Jul-09 6:19 
GeneralRe: Listbox Control giving NULL reference exception Pin
PDTUM14-Jul-09 6:32
PDTUM14-Jul-09 6:32 
GeneralRe: Listbox Control giving NULL reference exception Pin
PDTUM14-Jul-09 6:22
PDTUM14-Jul-09 6:22 
QuestionI have a problem with ajax pro dll Pin
manikandaprasad14-Jul-09 2:49
manikandaprasad14-Jul-09 2:49 
AnswerRe: I have a problem with ajax pro dll Pin
Christian Graus14-Jul-09 5:17
protectorChristian Graus14-Jul-09 5:17 
AnswerRe: I have a problem with ajax pro dll Pin
Not Active14-Jul-09 5:43
mentorNot Active14-Jul-09 5:43 

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.