I need How to Dynamically Create TextBox control.

Posted by Jayakumars under Regular Expressions on 6/29/2011 | Points: 10 | Views : 20924 | Status : [Member] [MVP] | Replies : 4
hi
i need Dynamaic create textbox in my Gridview below my gridview design

<asp:GridView ID="Grd1" runat ="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
here i need text box control then how to access them because control genrated
dynamically so i didnot control id so
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

Mark as Answer if its helpful to you


Responses

Posted by: Lakn2 on: 6/29/2011 [Member] Starter | Points: 25

Up
0
Down
<itemtemplate>

<asp:textbox id="tb1" runat="server" text='<#Eval('colname')>'></textbox>
</itemtemplate>

now call using like

textbox tb=(textbox)(gridview1.rows[e.rowindex].findcontrol("tb1");

now u can access textbox values using tb;


Thanks&Regards
LakshmiNarayana Nalluri.

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 6/30/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Check this link

http://www.aspsnippets.com/Articles/Adding-Dynamic-Rows-in-ASP.Net-GridView-Control-with-TextBoxes.aspx

Thanks
Karthik
www.f5Debug.net

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response