Dear,
Can anyone tell me how to add controls dynamically into webgrid? If there are 3 rows, then all the 3 rows should display the control. On adding a new row, control should display it the new row also. The datasource for the webgrid I will use is datatable.
Thanks in advance
Hi,
I am attaching a sample for you to look at. This sample creates a class inheriting from ITemplate and applies this to the C1TemplateColumn. This also shows how the template will function when you add a new row. I hope this helps.
-Raleigh
Thanks a lot. It worked perfectly.
Your sample works perfectly. I modified it to put textboxes in all cells [e.g. Product, Rate, Quantity, Gross] and coded in javascript to calculate gross [Rate*Quantity]. Now my problem is that all the typed values losts on page refresh. Can you show me a way to persists the typed in value in the control after post back.
Thanks.
I apologize for the delay in my response. I think it will be necessary for you to maintain these values manually when using the ITemplate in code. For instance, you could save these TextBox values to a database or perhaps to an array before the postback, but the best approach would depend on your scenario. After the page loads from the PostBack, you could then just apply the ITemplate again and fill in the values. I hope this helps.