Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!I have a gridview on my form and that gridview has fields.Among the fields there 2 fields that I dont want them to be visible to the user.What I ve did is to delete them but it keep DataKeyNames="EventsID,Id_Stadium".Those are the fieds that I am talkin about.Events is a primary key and Id_Stadium is foreign key.
then my problem is when selecting a row it should give me the specifik information by displaying the 2 fields on the other form.
I am using the bellow method to do that.But It dispaly on the other form the EventID 2 times.Help fixing this!

C#
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
      int newIndex = e.NewSelectedIndex;//Row that the user is selecting(!e is a parameter)
      object EventID = GridView1.DataKeys[newIndex].Value;
      object stadiumID = GridView1.DataKeys[newIndex].Value;
          string Game = GridView1.Rows[newIndex].Cells[0].Text;
      string Location = GridView1.Rows[newIndex].Cells[1].Text;
      string Stadium = GridView1.Rows[newIndex].Cells[2].Text;
      string Date = GridView1.Rows[newIndex].Cells[3].Text;
      string Hour = GridView1.Rows[newIndex].Cells[4].Text;
      Session["data"]= string.Format("Event:{0}<br />Location:{1}<br />Stadium name:{2}<br />Date:{3}", Game, Location, Stadium, Date);
      Session["StadeID"] = stadiumID;
      Session["EventID"] = EventID;
      Response.Redirect("BuyTicketPage.aspx");

}
Posted
Updated 6-Mar-12 3:31am
v3
Comments
Mahmud Hasan 6-Mar-12 8:45am    
Can you re-phrase your problem. By the way edited your question for better code formatting.
Shahin Khorshidnia 6-Mar-12 9:20am    
What's the name of current page? BuyTicketPage.aspx or other?

1 solution

Hello

C#
If(IsPostBack)
   Response.Redirect("BuyTicketPage.aspx");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900