Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here i've posted some wrong code, so i just remove my question.
Sorry for this.
Posted
Updated 9-Jul-13 2:44am
v3

Add Eval to each of the textboxes that you want to bind with the data from datatable.

ASP.NET
<asp:textbox id="txtBenid" enabled="false" runat="server" xmlns:asp="#unknown"></asp:textbox>


This is your code for the textbox in which you want id value to be binded.
Modify your code as:

ASP.NET
<asp:textbox id="txtBenid" enabled="false" runat="server" xmlns:asp="#unknown">Text='<%# Eval("id") %>'></asp:textbox>


Similary add for other textboxes too.
 
Share this answer
 
Comments
sahabiswarup 9-Jul-13 7:11am    
Thanks
Priyanka7777 9-Jul-13 7:33am    
Did this solution work for you?

Mark as answer if it worked for you.....
in for loop to decrease the dt.Rows.Count-1



C#
for (int i = 0; i < dt.Rows.Count-1; i++)
           {
               dr = dtTemp.NewRow();
               dr["id"] = dt.Rows[i][0].ToString();
               dr["Benificiary"] = dt.Rows[i][1].ToString();
               dr["Progress"] = string.Empty;
               dr["Remarks"] = string.Empty;
               dtTemp.Rows.Add(dr);
           }
 
Share this answer
 
Comments
sahabiswarup 9-Jul-13 7:11am    
Thanks
Raju Bollam 9-Jul-13 7:15am    
Accept as answer if solve you problem.
You have to change the above code as below :You have to give ids of text boxes as data column,Not the header text.

C#
dtTemp.Columns.Add(new DataColumn("txtBenid", typeof(string)));
       dtTemp.Columns.Add(new DataColumn("txtBen", typeof(string)));
       dtTemp.Columns.Add(new DataColumn("txtProg", typeof(string)));
       dtTemp.Columns.Add(new DataColumn("txtRem", typeof(string)));


Sample : http://matifnadeem.blogspot.com/2013/05/adding-dynamic-rows-in-aspnet-gridview.html[^]

I hope this will help to you.
 
Share this answer
 
v2
Comments
sahabiswarup 9-Jul-13 7:11am    
Thanks
Sampath Lokuge 9-Jul-13 7:16am    
@sahabiswarup which solution solved your issue ?
sahabiswarup 9-Jul-13 8:41am    
i changed my code logic after read your solution
Sampath Lokuge 9-Jul-13 8:56am    
@sahabiswarup what happened? Is that solved your problem or what ?
sahabiswarup 10-Jul-13 0:54am    
actually the logic is bit different, i want to generate grid row as per one DB table record and there i want to add textbox dynamically. finally fillup the dynamically created textbox value i want to save them. That's what i want and i solve it myself, thanks to all for your suggestion.

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