0

I am creating a ticket sales application and I am having a little trouble with the passing some of the final values I needed.
I need the event ID from the ticket that is being purchased but I fill the form I need with the ticket ID already. It is being passed already on the page from the previous page when I select the event I need.
I need a way to convert the event ID from the label that is hidden on the page and pass it to the final page, along with the ticket ID as well (the ticket ID is what is being passed).
Here is what I am working with:

<asp:GridView ID="grdvSeats" runat="server" DataKeyNames="SeatID" 
              AutoGenerateColumns="False" allowsorting="false" AllowPaging="false" 
              emptydatatext="No records match the criteria provided." BorderWidth = "1px">
     <Columns>
        <asp:HyperLinkField DataTextField="SeatName" 
                            DataNavigateUrlFields="SeatID" 
                            DataNavigateUrlFormatString="~/CheckOut.aspx?id={0}**&eID=lblEventID.Text**" 
                            HeaderText="Name" SortExpression="SeatName" /> 
     </Columns>
</asp:GridView>

1 Answer 1

1

OK, I don't completely follow that, but I think what you're saying is that from the first page, you pass the event ID, and then on this page, you assign the seat ID, and then you pass both of them to the final page. My suggestion is based on that assumption, but if I've got the order wrong, you can adjust appropriately.

You might have to set your DataNavigateUrlFormatString from code-behind. I'm assuming (since you mention the Event ID being set in a label) that you have it available in the code-behind. So, somewhere before you call DataBind on the GridView, execute the following code:

// I'm assuming this is the 1st column, as it was in your grid example
HyperLinkField hfield = grdvSeats.Columns[0] as HyperLinkField;           
string urlFormat = "~/CheckOut.aspx?id={0}&eID=" + eventID.ToString();
hfield.DataNavigateUrlFormatString = urlFormat;

Thus your DataNavigateUrlFormatString will reflect your EventID, and databinding will assign the SeatID in your GridView.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much, that did the trick perfectly. Since I'm not using text based searches, I am doing all means of searching by drop down lists and grid views populating from those values selected. I was passing the event ID from a previous page's gridview to get the venue and section IDs. I just needed to pass the final seatID in from section and the event ID linked to that seat.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.