开发者

ASP.NET list of checkboxes, each with an associated textbox

I'm trying to build a list of checkboxes, each one with a textbox/textarea associated to it.

The plan is for it to look something like this

[checkbox]

[textbox]

[checkbox]

[textbox]

[checkbox]

[textbox]

etc.

The title of each checkbox & textbox will be populated from the database.

I'm not really sure how to go about doing this.

Any help would be greatly a开发者_运维百科ppreciated.

Thanks.


The easiest solution will be to create a user control.

In that control you can have a label, a textbox and a checkbox. Create public properties for setting the values such as the label text and retrieving values such as textbox.Text and Checkbox.Checked

You can then add this control to your asp.net page as many times as you like either manually or programmatically.


You can begin with a table structure to store text/check boxes ,something like

<table class="style1">
        <tr>
            <td>
                <asp:CheckBox ID="CheckBox1" runat="server" />
            </td>
        </tr>
        <tr>
            <td>
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            </td>
        </tr>

    </table>

Then set properties that you need during the page load event. Or if you plan to use it more than once it'll be a good idea to pack everything into a user control

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜