Click to See Complete Forum and Search --> : Receiving Parameters


mlawton40
February 28th, 2007, 04:49 AM
Hi I have a link which sends a parameter with it:


<a href='FileList.aspx?doc_area_id=<%# Eval("doc_area_id") %>' >


I know I can get and use the passed parameter in the behind code by doing:


int areaId = 0;

if (Request.QueryString["doc_area_id"] != null)
{
areaId = Convert.ToInt32(Request.QueryString["doc_area_id"]);
}


but how can i recieve it in an aspx file and use it in a sqlsource select statement for a gridview criteria?

Any help would be great, Cheers, Mark.

mcmcom
February 28th, 2007, 09:42 AM
im assuming you want it as a parameter in a FRONT SIDE SqlDataSource select statement. ? one thats placed on the FileList.aspx page.

you can use a Query String Parameter. It goes in under the SelectParameters tag in your SqlDataSource looks like this


<asp:SqlDataSource id="blah" runat="Server" SelectCommand="Select * from here where this = @that">
<SelectParameters>
<asp:QueryStringParameter id="that" Type="Int32" QueryStringValue="doc_area_id"/>
</SelectParameters>
</asp:SqlDataSource>


i may have messed up the property names but intellisense will tell you what to put in.
you can spec Querystring parameter name, type, and a couple other things.

hth,
mcm