Saturday, March 24, 2012

Passing 2 variables through query string

Hi,

I know normally how to pass a value through a query string but this is complicated by wanting to pass two values. The first value is passed from a datagrid hyper link column i.e

<asp:HyperLinkColumn DataNavigateUrlField="PK_StockOrderID" DataNavigateUrlFormatString="AssignedDetail.aspx?id={0}"
DataTextField="PK_StockOrderID" HeaderText="Order ID"></asp:HyperLinkColumn>


This allows the user to view order details in the next page by passing the order id through the query string to the next page. However I also have a dropdown list box on the same page as the datagrid and would like to pass another parameter in the same query string based on the value selected in the list box.

Any ideas how I can do this?

If this doesnt make sense pls say and I will explain further.

Will something like this work if I have a function in my codebehind which returns the value of the dropdown list?
<asp:HyperLinkColumn DataNavigateUrlField="PK_StockOrderID" DataNavigateUrlFormatString="AssignedDetail.aspx?id={0} ?site=<%# ReturnSite %>"
DataTextField="PK_StockOrderID" HeaderText="Order ID"></asp:HyperLinkColumn>Normaly additional parameters in a querystring are separated by an ampersand (&)... not the ? (that's only on the first one to mark the begining of the QS.) and no spaces.

-tg
it's not calling the function at the moment I think this is the problem syntax

<asp:HyperLinkColumn DataNavigateUrlField="PK_StockOrderID" DataNavigateUrlFormatString="AssignedDetail.aspx?id={0}&site='<%# ReturnSite %>'"
Change of plan. Can I use the selected index changed property to set the DataNavigateUrlFormatString. That would be better but I cannot find the correct syntax?
Honestly, it's out of my realm of expertise... I've not had the chance to delve into ASP.NET, so I don't know for sure what the proper syntax is... I don't even know enough to point you in the right direction other than MSDN... Sorry...

-tg
Passed variable to a public class instead.
The ItemCommand event of the datagrid could have done this for you. Basically, you could retrieve the value from the Item that sent the Command (convert to DDL, get selected value) and then gotten the value from the standalone DDL in your page, concatenated them and then performed a Response.Redirect.

0 comments:

Post a Comment