0

I am new to ASP.NET. I am using C# and .Net Framework 4.

I am used to using asp classic and would like your help to do the below.

I have created a stored procedure that returns four rows.

Below is part of the asp.net code, which I am using to display the result.

Obviously, it is only displaying the first record from the query.

How would I go about looping it so that it will display all four records, one after the other?

Any help would be appreciated.

Thanks

<tr>
                                <td width="40%">
                                    <asp:TextBox ID="txtBenefit" runat="server" Text='<%# Bind("Benefit") %>' Width="98%"></asp:TextBox>
                                </td>
                                <td width="15%">
                                    <asp:CheckBox ID="cbActive" runat="server" Checked='<%# Bind("Active") %>' />
                                </td>
                                <td width="15%">
                                    <asp:CheckBox ID="cbDependant" runat="server" Checked='<%# Bind("AvailableDependant") %>' />                                </td>
                                <td width="15%">
                                    <asp:CheckBox ID="cbImmediate" runat="server" Checked='<%# Bind("ImmediatelyAvailable") %>' />
                                </td>
                            </tr>

Edited by ajwposh: n/a

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by MichaelWClark
0

Wich control are you using? The ListView and Gridview controls are good for displaying several rows.

0

I am not using either because I need to display checkboxes as the user needs to be able to click the checkboxes and then update the form.

Am I able to do checkboxes within a gridview etc?

0

You can add check boxes, or any control to grid view, or list view. You just need to use Template fields for creating the custom controls. For some of my code I like to use a repeater for adding a bit more control and formatting ease, but all of them are good if used properly. You should note that if you need to access a control inside of a gridview, listview, repeater etc, you will need to use the FindControl function : ex

dim chkBox as CheckBox = ctype(Repeater1.FindControl("CheckBox1"),CheckBox)
if chkBox.Checked = true then
...
end if

C#

CheckBox chkbox = (checkbox)repeater1.FindControl("Checkbox1");
if(chkBox.Checked){ .. }

..forgive me if I err'd in my C# I primarily use VB.net at my job, either way you should get the idea.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.