how to pass 2 fields in a Hyperlink from a Datagrid

  • Thread starter Thread starter J Sahoo
  • Start date Start date
J

J Sahoo

Hello,
I want to pass 2 fields (composite key) to another aspx page. I have 2
database fields (Provider_code, Location_Code) shown on my datagrid.
If the user clicks on the Edit (hyperlink), I want to call
MaintProvider.aspx with Provider_code & Location_Code. With the code
below I was able to pass only 1 field, how can I pass the 2nd field?
For each record the Location_Code will change, so I can't hardcode the
value.

Please provide me some sample example how to do this task. Thank you
in advance.

Sahoo J



<asp:HyperLinkColumn Text="Edit" DataNavigateUrlField="Provider_Code"
DataNavigateUrlFormatString="MaintProvider.aspx?parmProvCode={0}&amp;usrAction=Edt">

<HeaderStyle Font-Bold="True"></HeaderStyle>
 
try this wa

<asp:HyperLinkColumn Text="Edit" DataNavigateUrlField="Provider_Code
DataNavigateUrlFormatString="MaintProvider.aspx?parmProvCode=<%# DataBinder.Eval(Container, "DataItem.X")%>&NextProvCode =<%# DataBinder.Eval(Container, "DataItem.Y")%>&usrAction=Edt">
 
Just received a message from the group to use "template column" to
accomplish this task. Can anybody provide me a sample code please?
Thanks.

Sahoo J
 
Finally I was able to fix my problem. May be it will help somebody
else who may need the solution later. Here it goes:

<asp:TemplateColumn HeaderText="Composite Key">

<ItemTemplate>
<a href='FrmLogin.aspx?myParm=<%# Container.DataItem("Location_ID")
%><%# Container.DataItem("Provider_Code") %> '> Click here </a>
</ItemTemplate>

</asp:TemplateColumn>



Thanks.

Sahoo J
 
Thanks! your posting helped me. The Template column was not very intuitive at first.
 
Back
Top