Last post Apr 22, 2008 01:31 AM by Nai-Dong Jin - MSFT
Apr 16, 2008 06:54 PM|800613|LINK
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????
Apr 17, 2008 05:20 AM|DiscernIT|LINK
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">
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("MyDataField") %>'></asp:TextBox>
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)
Apr 17, 2008 04:40 PM|800613|LINK
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.
Apr 18, 2008 05:27 PM|800613|LINK
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???
Apr 22, 2008 01:31 AM|Nai-Dong Jin - MSFT|LINK
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.
After that, you can access each textbox in the list, and add it to the control collection while overriding the CreateChildControl event.