Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
All Please find the below code.
Here i am creating dynamically table and for that table also i am adding dynamical text boxes.My problem is in middle tier how can i get the textbox(multiple textboxes) value.
Please help any one.

function BindTable1() {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "WebDesigner.aspx/BindDatatable2",
data: "{}",
dataType: "json",
success: function (data) {
for (var i = 0; i < data.d.length; i++) {
$("#tbDetails1").append("
" + data.d[i].Field_text + "" + ':' + "<input id='txtDetails11" + i + "' type='text' />
");
}
},
error: function (result) {
alert("Error");
}
});
}
Posted

1 solution

Hi all the dynamically created controls are available in Request.From Collection object.

You can access them in postback as

C#
for(int i=0;i<request.form.count;i++)>
{
  string value = Request.Form["txtDetails"+i].ToString();
}


In your case you can loop 2 times(to append row and column id in your case) to get all the textbox values you have created.
 
Share this answer
 
v3
Comments
BalaMahesh 26-Dec-12 9:39am    
On Save button click event i wrote the same code as per me but its getting Object reference not set to an instance of an object error.
BalaMahesh 28-Dec-12 2:54am    
Please give me any alternate solution for this.
Rakesh6906 28-Dec-12 8:00am    
Before I have done in the following approach. but here the processing happens on server side..

1. I have created a webmethod in c#,which uses HTMLTable class and create a HTML Table(based on params), Textboxes have been added to the table Cell.
2. Converted above HTMLTable to Html Table markup and returned the html as text to the jquery ajax function.
3. on success i have placed the returned HTML in a div. On postback the all the controls were available in Request.Form object.

You can use this method, depending on your requirements.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900