Thursday, March 29, 2012

Passing values from a datagrid w/ a HyperLinkColumn

I have successfully populated my datagrid. It consists of only one column. THis column is a link. What I am trying to do is send the text of the link (also what is pulled from the DB) to the aspx page that the link submits to.

I'm open to all suggestions as I'm new and trying to learn all different ways possible.

Thanks!

HDYour column should look like this :


<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="DepartmentID" DataNavigateUrlFormatString="default.aspx?DepartmentID={0}"
DataTextField="DepartmentName" HeaderText="Departments :" ItemStyle-CssClass="side "></asp:HyperLinkColumn>
</Columns>

The DataNavigateUrl field gets placed where the {0} is in the DataNavigateUrlFormatString. DataText is the displayed link text.

On the next page you can pick up the value using Request.Params("DepartmentID")

Simon
Great thanks. However I am receiving the following where I try to do the Request.Params("fieldName").


"'System.Web.HttpRequest.Params' denotes a 'property' where a 'method' was expected"

The line of code throwing the error is :


TextBox1.Text = Request.Params("SelectedCategory");

Thanks for your help, and forgive the stupid questions.

HD
Nevermind. I figured it out. I changed the line of code to

Request.Params.Get("SelectedCategory")

HD

0 comments:

Post a Comment