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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:37:35+00:00 2026-06-15T18:37:35+00:00

I have my gridview set where the user can select the row they want

  • 0

I have my gridview set where the user can “select” the row they want which in turn should go through the database and redirect them. However, when I click on “select” for any given row of results I get the error “Input string was not in correct format” at this line: myEvent.EventID = Convert.ToInt32(row.Cells[0].Text); I took this piece out and I get the error for ever line with the Convert in it. So I know it’s not written correctly but I’m unsure how to write it. Any help would be great!

sorry I’m new at this!

My code for the girdview:

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Event myEvent = new Event();
        GridViewRow row = GridView1.SelectedRow;
        myEvent.EventID = Convert.ToInt32(row.Cells[0].Text);
        myEvent.Sport = row.Cells[1].Text;
        myEvent.EventName = row.Cells[2].Text;
        myEvent.Section = Convert.ToInt32(row.Cells[3].Text);
        myEvent.TicketsAvailable = Convert.ToInt32(row.Cells[4].Text);
        myEvent.EventDate = Convert.ToDateTime(row.Cells[5].Text);
        Session["myEvent"] = myEvent;

        Response.Redirect("Complete.aspx");
    }

My code for the Event in case you need it also:

public class Event
{
    public int EventID { get; set; }
    public string EventName { get; set; }
    public string Sport { get; set; }
    public int Section { get; set; }
    public int TicketsAvailable { get; set; }
    public DateTime EventDate { get; set; }
}
  • 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-15T18:37:36+00:00Added an answer on June 15, 2026 at 6:37 pm

    Just check weather the Value that you are converting is not null. try to debug the code and check what are the values you are getting from that particular row.

    another thing is if you have created generated Select Button in the gridview then the position of that select button is at 0 cell of gridview. so you can try your code like this.

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Event myEvent = new Event();
            GridViewRow row = GridView1.SelectedRow;
            myEvent.EventID = Convert.ToInt32(row.Cells[1].Text);
            myEvent.Sport = row.Cells[2].Text;
            myEvent.EventName = row.Cells[3].Text;
            myEvent.Section = Convert.ToInt32(row.Cells[4].Text);
            myEvent.TicketsAvailable = Convert.ToInt32(row.Cells[5].Text);
            myEvent.EventDate = Convert.ToDateTime(row.Cells[6].Text);
            Session["myEvent"] = myEvent;
    
            Response.Redirect("Complete.aspx");
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I have a GridView with an ObjectDataSource, and I want to programmatically set
i need to set image as background in android gridview. I have code which
Have a gridview control which will show X amount of rows. I want to
I have a gridview in which a specific column Date . I have set
I have a set of categories that a user can choose from. Each category
I have a gridview which has rows of 'tickets'. A user has the ability
I have to set GridView.DataKeyNames (This is really a question about the syntax for
I have a asp:GridView with a HyperLinkField . It's DataNavigateUrlFormatString property is set to
I have a gridview and I have a button on it.I want, if the
I have a gridview with pictures of equipment to select from. Once selected, the

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.