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

  • SEARCH
  • Home
  • 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 6545537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:35:51+00:00 2026-05-25T11:35:51+00:00

I’m looking to have a GridView displaying Events from a database, and then in

  • 0

I’m looking to have a GridView displaying “Events” from a database, and then in the last column I want to do another database lookup (for each row) to see if that event is full or not.

If it’s not full, display a radio button. If it is full display text “Full”.

I think this is best done with OnRowDataBound event but could use a little help.

I can see how to change an asp label text but not display a radio button.

register.aspx:

<asp:GridView ID="GridView2" runat="server" DataSourceID="SqlDataSource2" AutoGenerateColumns=false CellPadding="5" HeaderStyle-BackColor="DarkGray" Width="450px" OnRowDataBound="GridView2_OnRowDataBound">
            <Columns>
                <asp:BoundField DataField="sessionDate" HeaderText="Date" DataFormatString="{0:D}" />
                <asp:BoundField DataField="sessionTime" HeaderText="Time" />
                <asp:BoundField DataField="site" HeaderText="Site" />
                <asp:BoundField DataField="room" HeaderText="Room" DataFormatString="{0:D}" />
                <asp:TemplateField HeaderText="">
                    <ItemTemplate>
                        <input type="radio" name="rdoSessionID" value='<%# Eval("ses_ID") %>' />



                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <HeaderStyle BackColor="#99CCFF" />
        </asp:GridView>
        <br />


        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:sqlConnection2 %>"
            SelectCommand="SELECT * FROM dbo.sessions WHERE site LIKE @ses_site AND sessionDate = @ses_date ORDER BY sessionDate">

            <SelectParameters>
             <asp:SessionParameter name="ses_site" SessionField="ses_site" Type="String" />
             <asp:SessionParameter name="ses_date" SessionField="ses_date" Type="String" />
            </SelectParameters>



        </asp:SqlDataSource>
  • 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-05-25T11:35:51+00:00Added an answer on May 25, 2026 at 11:35 am

    There are a few ways you can do this.

    1. You can do this on the OnRowDataBound , If the Item you’re dealing with is a DataItem, grab the value you need from the current row, and do a quick DB Lookup
    2. When you get your resultset back from the database, do another lookup on each event. This way when your data leaves your data layer / methods you already have everything you need.
    3. Modify your SQL query to return this information with the list of events. You already know the Events, you could just have a sub query to query to see if it’s full or not (or the # of people registered, and the Max # allowed so you can show that). This way you only have to do 1 hit against the database and it will save you a bunch of processing. (My favorite)

    You would still need to overload the OnRowDataBound event for all 3 of those solutions. You’d hide the radio button if it was full, and ensure it was visible if the event was not full. The difference is where do you get your data.

    Do you want to do:

    1 Good hit (list of events)
    X amounts of small hits for each event

    or

    1 Good hit for list of events + if each event is full or not.

    If you want to entertain #3, post your SQL Query and we can go from there.

    Quick example of the OnRowDataBound event.

    protected void MyGridView_OnRowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            CheckBox cbox = (CheckBox)e.Row.FindControl("chkBox");
    
            // Do some funky logic
            cbox.Visible = Event.HasRoom; //Boolean Propery
            // Or
            cbox.Visible = Convert.ToBoolean(DataBinder.Eval(e.Row.DataItem, "HasRoom").ToString());
    
        }
    }
    

    Update 1:

    For your GridView, You can use

    <ItemTemplate> 
       <asp:CheckBox runat="server" ID="Checkbox1" ToolTip=" Sign up For event " text="Event stuff" /> 
    </ItemTemplate>
    

    If you want to use a template, don’t use a regular control, use a control.

    For the query you could do the following. I’m not 100% sure on your table structure so I did it the way I normally would:

    Table: Session (sess_id(PK), SessionDate, SessionTime, Site, Room)
    Table: Registrants (RegistrantID (PK), sess_id (FK to Session), UserID (FK to users that are registered)

    SELECT SessionDate, SessionTime, Site, Room, ses_ID, 
    (SELECT Count(ses_ID) FROM Registrants R WHERE R.Ses_ID= S.ses_Id) as [Registrants]
    FROM dbo.Sessions s
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a French site that I want to parse, but am running into
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a text area in my form which accepts all possible characters from
I have a reasonable size flat file database of text documents mostly saved in
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has

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.