0

For example this is the table:

<table id="users">
<thead>
  <tr class="ui-widget-header ">
    <th>Name</th>
    <th>Email</th>
    <th>Password</th>
  </tr>
</thead>
<tbody>
  <tr>
    <td><input type="text" value="Name1"/></td>
    <td><input type="text" value="Email1"/></td>
    <td><input type="text" value="Password1"/></td>
  </tr>  <tr>
    <td><input type="text" value="Name2"/></td>
    <td><input type="text" value="Email2"/></td>
    <td><input type="text" value="Password2"/></td>
  <tr>
</tbody>
</table>

then I want the codebehind to get the values from the table.. please help.

1
  • i tried foreach(Contron ctrl in users.Control).. but its not working Commented Apr 21, 2012 at 11:15

2 Answers 2

2

Create table to run at server like this

<table id="users" runat="server">

and you will be able to access it using HtmlTable class. Have a look at http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmltable%28v=vs.80%29.aspx

Sign up to request clarification or add additional context in comments.

Comments

2

You have to use the <asp:TextBox> tag instead of the <input> tags. This enables you to get the values from the text boxes in codebehind.
See the System.Web.UI.WebControls.TextBox documentation on MSDN.

UPDATE:
If you can't change the <input> tags to <asp:TextBox>, you could access the form values posted through Request.Form like this:

Request.Form[valueName]

Where value name is the name of the value posted.

4 Comments

So input text is not possible? Actually Im adding row dynamically using javascript and i cant put there asp tags.. quite similar to this jqueryui.com/demos/dialog/#modal-form
If you want to access the values from codebehind you can't use <input>. The answer from @Ravindra provides another possibility, but still you can't add a row dynamically from javascript.
$("#users tbody").append("<tr>" + "<td><input type='text'class='customerIDCell'/></td>" + "<td><input type='text'class='customerIDCell'/></td>" + "<td><input type='text'class='customerIDCell'/></td>" + "</tr>"); This is how i create row and its working but i cant change that input to aspTextbox I keep using input
You could use Request.Form to access the values posted through the form. See msdn.microsoft.com/en-us/library/….

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.