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 520071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:06:24+00:00 2026-05-13T08:06:24+00:00

Background I have a GridView where input in Column1 depends on the input Column2

  • 0

Background

I have a GridView where input in Column1 depends on the input Column2.

  • If a user enters a N in Column2 the system will put a Y in Column1.

The Validatons are implemented using Regexs and Custom validation. I would prefer a validation solution that doesn’t use JavaScript.

|Column1| Column2|
__________________
| Y     | N
__________________
|N      | Y
__________________
|N      | N

Question

How can I validate these entries in the Gridview without using JavaScript?

  • 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-13T08:06:24+00:00Added an answer on May 13, 2026 at 8:06 am

    You could use radio buttons and the ‘Template’ column feature of a GridView. The GridView markup would look like this:

        <asp:GridView ID="gvTest" runat="server" AutoGenerateColumns="false" 
            OnRowDataBound="gvTest_RowDataBound">
            <Columns>
                <asp:TemplateField HeaderText="Column 1">
                    <ItemTemplate>
                        <asp:RadioButton ID="rbSelect1" runat="server" Text="" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Column 2">
                    <ItemTemplate>
                        <asp:RadioButton ID="rbSelect2" runat="server" Text="" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    

    The trick then would be to correctly set the ‘GroupName’ property of each radio button so that each row of the resulting grid is treated as a single radio button group by the browser. That’s where the ‘OnRowDataBound’ handler specified on the grid comes into play. The definition of the ‘gvTest_RowDataBound’ handler method could be something like:

    protected void gvTest_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            RadioButton rb1 = (RadioButton)e.Row.FindControl("rbSelect1");
            RadioButton rb2 = (RadioButton)e.Row.FindControl("rbSelect2");
            rb1.GroupName = rb2.GroupName = string.Format("Select_{0}", e.Row.RowIndex);
        }
    }
    

    By appending the row index to the group name to both of the radio buttons in each row you’re going to ensure that the browser will treat them as a group and only allow the selection of one value per row. The result would look something like this:

    GridView screenshot

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 439k
  • Answers 440k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I suspect that you are using either @Cacheable or @Cache… May 15, 2026 at 5:05 pm
  • Editorial Team
    Editorial Team added an answer Save all records to the database using myDate.ToUniversalTime() When loading… May 15, 2026 at 5:05 pm
  • Editorial Team
    Editorial Team added an answer The model is your business logic and business objects. Many… May 15, 2026 at 5:05 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.