Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7911755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:21:52+00:00 2026-06-03T13:21:52+00:00

I want to generate checkbox field using GridView and system will calculate how many

  • 0

I want to generate checkbox field using GridView and system will calculate how many field to display according to number of totalDay.
If totalDay stored in database is 7, so upon calling the eventID it will generate 7 checkboxes, D1-D7 checkboxes field will appear; if totalDay is 5, it will generate 5 checkboxes, D1-D5 checkboxes field will appear.

In PHP, I manage to auto generate number of D field I want according to value totalDay. But I do not know how to code in VB.

The PC Fair Event has duration 7 days, so it will display 7 checkboxes after user select event and booth to book:
enter image description here

The Carnival 2012 has duration 5 days, so it will display 5 checkboxes after user select event and booth to book:
enter image description here

The code in PHP which can generate the checkbox:

$query = "select * from booths, eventinfo where booths.eventID=eventinfo.eventID && booths.eventID = ".$id."";

$_SESSION['EVENT_ID']=$id;
$result = mysql_query($query);
$result2= mysql_query($query);


echo "<table border='0' style='width:400px;table-layout:fixed'>";


$rows2 = mysql_fetch_array($result);
$Day=$rows2['totalDay'];
echo "<table>";
for ($day = 0; $day <= $Day; ++$day) {
    if($day==0){
        echo "<th>Booth</th>";
    }else{
         echo "<th>D".$day."</th>";
    }
}

while($rows = mysql_fetch_array($result2)){
    $boothAlias=$rows['boothAlias'];
    $totalDay=$rows['totalDay'];
    $boothID=$rows['boothID'];


    echo "<tr><td>$boothAlias</td>";
    for ($day2 = 1; $day2 <= $totalDay; ++$day2) {

        $d=$rows["D$day2"];

        if ($d==0){
            echo "<td><input name='totalDay[]' type='checkbox' value='$boothAlias $boothID $day2'/></td>";

        }else{
            echo "<td><input name='totalDay[]' type='checkbox' value='$boothAlias $day2' disabled='true'/></td>";
            }
        }
        echo "</tr>";
}

echo "</table>";
}
}

I do not how to call the totalDay value and do the looping to check D field in VB.
Is there any better solution to generate checkbox?
Can it reused only one itemtemplate to generate checkbox and bind with D field?

Following is my current VB code:

<%@ Page Language="VB" MasterPageFile="~/MasterPageMember.master" AutoEventWireup="false" CodeFile="member_view_event_list.aspx.vb" Inherits="member_view_event_list" title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">



</asp:Content>

<asp:Content ID="ContentPlaceHolder2" runat="server" 
contentplaceholderid="ContentPlaceHolder2">



<table width="80%">
    <tr><td class="style10">&nbsp;</td><td class="style8">&nbsp;</td><td>&nbsp;</td></tr>
    <tr><td class="style10">
        <asp:Label ID="Label1" runat="server" Text="Select Event:"></asp:Label>
    </td><td class="style8">
        <asp:DropDownList ID="ddlEventList" runat="server" 
            DataSourceID="SqlDataSourceEvent" DataTextField="eventTitle" 
            DataValueField="eventID" AutoPostBack="True" Width="200">

        </asp:DropDownList>
        <asp:SqlDataSource ID="SqlDataSourceEvent" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>" 
            SelectCommand="SELECT DISTINCT [eventTitle], [eventID] FROM [booth_eventinfo]">
        </asp:SqlDataSource>
    </td><td>
            &nbsp;</td></tr>


    <tr><td class="style10">
        <asp:Label ID="Label2" runat="server" Text="Select Booth:"></asp:Label>
        </td><td class="style8">
        <asp:DropDownList ID="ddlBoothList" runat="server" 
            DataSourceID="SqlDataSourceBooth" DataTextField="boothAlias" 
            DataValueField="boothID" AutoPostBack="True" Width="200">

        </asp:DropDownList>
        <asp:SqlDataSource ID="SqlDataSourceBooth" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>" 
            SelectCommand="SELECT [boothAlias], [boothID] FROM [booth_eventinfo] WHERE ([eventID] = @eventID)">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlEventList" Name="eventID" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        </td><td>
             </td></tr>


    <tr><td class="style10">
        &nbsp;</td><td class="style8">
            &nbsp;</td><td>
             &nbsp;</td></tr>


    <tr><td class="style9" colspan="3">

        <asp:GridView ID="GridViewDay" runat="server" AutoGenerateColumns="False" 
            CellPadding="4" DataSourceID="SqlDataSourceDay" ForeColor="#333333" 
            GridLines="None">
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <Columns>

                <asp:TemplateField HeaderText="Day1" SortExpression="D1" HeaderStyle-HorizontalAlign="Center">
                <ItemTemplate>
                <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("D1") %>' />
                </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Day2" SortExpression="D2" HeaderStyle-HorizontalAlign="Center">
                <ItemTemplate>
                <asp:CheckBox ID="CheckBox2" runat="server" Checked='<%# Bind("D2") %>' />
                </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Day3" SortExpression="D3" HeaderStyle-HorizontalAlign="Center">
                <ItemTemplate>
                <asp:CheckBox ID="CheckBox3" runat="server" Checked='<%# Bind("D3") %>' />
                </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Day4" SortExpression="D4" HeaderStyle-HorizontalAlign="Center">
                <ItemTemplate>
                <asp:CheckBox ID="CheckBox4" runat="server" Checked='<%# Bind("D4") %>' />
                </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Day5" SortExpression="D5" HeaderStyle-HorizontalAlign="Center">
                <ItemTemplate>
                <asp:CheckBox ID="CheckBox5" runat="server" Checked='<%# Bind("D5") %>' />
                </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Day6" SortExpression="D6" HeaderStyle-HorizontalAlign="Center">
                <ItemTemplate>
                <asp:CheckBox ID="CheckBox6" runat="server" Checked='<%# Bind("D6") %>' />
                </ItemTemplate>
                </asp:TemplateField>




            </Columns>


            <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSourceDay" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>" 
            SelectCommand="SELECT [D1], [D7], [D6], [D5], [D4], [D3], [D2] FROM [booth_eventinfo] WHERE ([boothID] = @boothID)">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlBoothList" Name="boothID" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        </td></tr>


    <tr><td class="style10">
        &nbsp;</td><td class="style8">
            &nbsp;</td><td>
            &nbsp;</td></tr>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:21:53+00:00Added an answer on June 3, 2026 at 1:21 pm

    I think you’d have a much easier time using the CheckBoxList control:

    <asp:CheckBoxList ID="CheckList1" runat="server" 
        RepeatLayout="Table" 
        RepeatDirection="Horizontal" 
        RepeatColumns="7" 
        DataTextField="DayName" 
        DataValueField="DayNumber">
    </asp:CheckBoxList>                  
    

    Then, in the code-behind, you just bind the list:

    Protected Sub Page_Load(sender As Object, e As EventArgs)
        If Not Page.IsPostBack Then
            CheckList1.DataSource = GetData()
            CheckList1.DataBind()
        End If
    End Sub                                   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to generate a random number with in two range, and i want
I want to generate some XML in a stored procedure based on data in
Using ASP.NET to generate several checkboxes. Looking for a JavaScript solution that will test
I want my Agree To Terms checkbox to be mandatory using jQuery validate, in
I am using Razor to generate a form. I want to create HTML elements
i'm want to have a repeater generate a bunch of checkboxes, e.g.: <tr><td><input type=checkbox
Let's say I have a class of 30 students and want generate every possible
I want to generate following xml output in my C# code : <?xml version=1.0
I want to generate a thumbnail preview of videos in Java. I'm mostly JMF
I want to generate some formatted output of data retrieved from an MS-Access database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.