datagrid passing parameters problem

L

Laura K

I have a datagrid with a hyperlink field. It passes a parameter but I need
it to pass three. I need two of the parameters to be querystrings that have
already been passed to the page but I have no idea how to add them the the
hyperlink column.

Here is the code to the hyperlink column

<asp:HyperLinkColumn
HeaderText="strProductName"
Visible="True"
DataTextField="strProductName"
DataNavigateUrlField="intProductID"
DataNavigateUrlFormatString="details.aspx?ProductID={0}"/>
<asp:BoundColumn DataField="curPrice"
HeaderText="curPrice"
ReadOnly="true"
Visible="True"/>

Here is the code if it were to be outside the datagrid.

<a href="details.aspx?prodID=<%# dsSubCategory.FieldValue("intProductID",
Container) %>&strCssPath=<%= Request.QueryString("StrCSSPath")
%>&strSubCategory=<%=
server.UrlEncode(Request.QueryString("strSubCategory")) %>">

I have taken care of the details.aspx?#
dsSubCategory.FieldValue("intProductID", Container) %>

but I do not know how to pass the existing parameters

Any help appreciated.

Thanks
Laura K
 
O

Otis Mukinfus

You will need to create a template column that contains an <a> element
instead of a HyperLinkColumn. You then can build the QueryString from
within the Template column.

I have a code example at work. I will post the sample this evening.



I have a datagrid with a hyperlink field. It passes a parameter but I need
it to pass three. I need two of the parameters to be querystrings that have
already been passed to the page but I have no idea how to add them the the
hyperlink column.

Here is the code to the hyperlink column

<asp:HyperLinkColumn
HeaderText="strProductName"
Visible="True"
DataTextField="strProductName"
DataNavigateUrlField="intProductID"
DataNavigateUrlFormatString="details.aspx?ProductID={0}"/>
<asp:BoundColumn DataField="curPrice"
HeaderText="curPrice"
ReadOnly="true"
Visible="True"/>

Here is the code if it were to be outside the datagrid.

<a href="details.aspx?prodID=<%# dsSubCategory.FieldValue("intProductID",
Container) %>&strCssPath=<%= Request.QueryString("StrCSSPath")
%>&strSubCategory=<%=
server.UrlEncode(Request.QueryString("strSubCategory")) %>">

I have taken care of the details.aspx?#
dsSubCategory.FieldValue("intProductID", Container) %>

but I do not know how to pass the existing parameters

Any help appreciated.

Thanks
Laura K

Otis Mukinfus
http://www.otismukinfus.com
 
O

Otis Mukinfus

Here is the sample I promised you...

<asp:TemplateColumn HeaderText="Supervisor">
<ItemTemplate>
<a runat="server"
href='<%# "supervisordisplay.aspx" +
"?supid=" + DataBinder.Eval(Container.DataItem, "supid") +
"&fullsupname=" + DataBinder.Eval(Container.DataItem, "supname") +
", " + DataBinder.Eval(Container.DataItem, "supinit") %>'>
<%# DataBinder.Eval(Container.DataItem, "supname") +
", " + DataBinder.Eval(Container.DataItem, "supinit") %>
</a>
</ItemTemplate>
</asp:TemplateColumn>


Otis Mukinfus
http://www.otismukinfus.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top