Answered by:
textboxlist

Question
-
User1985754105 posted
hi guys,
how to make a custom webserver controls??? i juz wanna try 2 make a web control similiar to checkboxlist, but the repeated control is textbox instead of checkbox. then i wanna connect it with database. the point is i juz wanna rate the items in my database using textboxes (not rating extender in ajaxcontroltoolkit). is it possible 2 make that such of "textboxlist"??? im new to make custom controls. can u guyz help me????
thx b4.
Wednesday, April 16, 2008 6:54 PM
Answers
-
User-1125720926 posted
you could:
add a new web user control to your project.
in the user control use a repeater or (a perhaps a datalist), stick a textbox in, bind to a datasource:
<asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("MyDataField") %>'></asp:TextBox> </ItemTemplate> </asp:Repeater>
alternatively you could have a propery on your web control that specifies the number of textboxes. use that number in code to populate the repeater with textboxes (could be done by binding the repeater to a dummy datasource (eg xmldocument or blank array) of that many items)
hth
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, April 17, 2008 5:20 AM -
User-1136466523 posted
Hi,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>Try to create a custom server control, and expose an List<TextBox> typed property, actually, you can add your textboxes into the list, and assign the textbox list to your custom server control.
<o:p> </o:p>After that, you can access each textbox in the list, and add it to the control collection while overriding the CreateChildControl event.
<o:p> </o:p>Thanks.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 22, 2008 1:31 AM
All replies
-
User-1125720926 posted
you could:
add a new web user control to your project.
in the user control use a repeater or (a perhaps a datalist), stick a textbox in, bind to a datasource:
<asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("MyDataField") %>'></asp:TextBox> </ItemTemplate> </asp:Repeater>
alternatively you could have a propery on your web control that specifies the number of textboxes. use that number in code to populate the repeater with textboxes (could be done by binding the repeater to a dummy datasource (eg xmldocument or blank array) of that many items)
hth
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, April 17, 2008 5:20 AM -
User1985754105 posted
but how to pass the value inside the textboxes to the codebehind? do i need to include n specify the commandargument inside asp:textbox tag? cuz i need to pass the value 1st to codebehind, process it to a function, n then send it to my database.
thx
Thursday, April 17, 2008 4:40 PM -
User1985754105 posted
i've tried 2 iterate the textboxes inside the repeater using repeater.findcontrol("textboxid") in codebehind, to pass the value inside the textboxes, but it seems that wont work. how exactly to iterate the textboxes inside the repeater so i could pass the value in codebehind???
thx.
Friday, April 18, 2008 5:27 PM -
User-1136466523 posted
Hi,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>Try to create a custom server control, and expose an List<TextBox> typed property, actually, you can add your textboxes into the list, and assign the textbox list to your custom server control.
<o:p> </o:p>After that, you can access each textbox in the list, and add it to the control collection while overriding the CreateChildControl event.
<o:p> </o:p>Thanks.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, April 22, 2008 1:31 AM