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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:22:08+00:00 2026-06-11T22:22:08+00:00

I am working on my first web project and I need help adding IF

  • 0

I am working on my first web project and I need help adding IF logic when using GridView. I have a page (CustomerListPage) that has a GridView item that displays a list of customers(rows) that can be clicked. Once the customer is clicked, the user is redirected to a page called “CustomerUsagePage” which shows the most recent record of this customer. This is what my GridView code looks like for my CustomerListPage:

 if (GridView1.SelectedRow.RowIndex == 0)
   {
       //string selectedUser = GridView1.SelectedRow.Cells[0].ToString();
       Response.Redirect("CustomerUsagePage.aspx?Customer_Name=" );
       BindGridview();
   }

The code for my CustomerUsagePage looks like this:

private void BindControlvalues()
{

    con.Open();
    SqlCommand cmd = new SqlCommand("select * from dbo.CustomerTable", con);
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    con.Close();
    DataSet ds = new DataSet();
    da.Fill(ds);
    Label4.Text = ds.Tables[0].Rows[0][1].ToString();
    Label1.Text = ds.Tables[0].Rows[0][0].ToString();
    Label2.Text = ds.Tables[0].Rows[0][3].ToString();
    Label3.Text = ds.Tables[0].Rows[0][4].ToString();
}

My problem is that I can only add IF logic the page where my GridView is located. I would like to click on a customer and have his data appear on my CustomerUsagePage with an if statement. Is it possible? I know I can do this by adding a page per customer but I dont want to go down that route, it seems to tedious. Does anyone have any suggestions?

  • 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-11T22:22:10+00:00Added an answer on June 11, 2026 at 10:22 pm

    You can use GridView-FormView (Master/Detail) Control

    Link : http://www.codeproject.com/Articles/16780/GridView-FormView-Master-Detail-Control.

    Or you can use classic behavior with ItemCommand event

    void GridView_RowCommand(Object sender, GridViewCommandEventArgs e)
    {
        if(e.CommandName=="Add")
        {
          int index = Convert.ToInt32(e.CommandArgument);
    
          GridViewRow row = CustomersGridView.Rows[index];
    
          .....//Adjust your Response
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project that has, amongst other things, one web application (mvc) and
I'm working on my first very complex JQuery based application. A single web page
I am working on a project where I need to embed a web server
I'm working on my first professional project. The fact is that I don't know
I'm working on a web site project that is currently tracked in svn but
FYI, I'm working on my first MVC web application using MVC 3 and Razor
Im stuck in my project here and i really need some help! I have
Now I'm working on a web project. I need to create a XML document
I am working on a web development project using flask and sqlalchemy orm. My
I'm working on my first real WinForms application, and my boss has asked that

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.