|
-
Aug 12th, 2005, 04:51 AM
#1
Thread Starter
Lively Member
[RESOLVED] Hyperlink in datagrid?
Hi,
asp.net code
using datagrid, column1 is my hyperlink and column2 is the database value.
Column1 Column2
View Info anm
Q: How can I get the result from my hyperlink that should be like this "name.aspx?nme=asp".
Thanks
-
Aug 12th, 2005, 05:37 AM
#2
Member
Re: Hyperlink in datagrid?
you would set up the hyperlink column something like this:
VB Code:
<asp:HyperLinkColumn
HeaderText="Column1"
DataNavigateUrlField="name"
DataNavigateUrlFormatString="name.aspx?name={0}"
Text="View Info" />
where DataNavigateUrlField is the field in the datasource which will provide the URL of the page. So if you have a unique ID field in the datasource called 'ID' you would put DataNavigateUrlField="ID" if you have a field called name which is unique then substitute name for ID.
-
Aug 14th, 2005, 07:25 PM
#3
Thread Starter
Lively Member
Re: Hyperlink in datagrid?
-
Aug 15th, 2005, 03:03 AM
#4
Thread Starter
Lively Member
Re: Hyperlink in datagrid?
 Originally Posted by basilisk
you would set up the hyperlink column something like this:
VB Code:
<asp:HyperLinkColumn
HeaderText="Column1"
DataNavigateUrlField="name"
DataNavigateUrlFormatString="name.aspx?name={0}"
Text="View Info" />
where DataNavigateUrlField is the field in the datasource which will provide the URL of the page. So if you have a unique ID field in the datasource called 'ID' you would put DataNavigateUrlField="ID" if you have a field called name which is unique then substitute name for ID.
Basilisk,
thanks for your reply...
Q: how about adding a value of textbox in HyperLinkColumn? 2 fields?
DataNavigateUrlFormatString="name.aspx?name={0}&xcde=???"
-
Aug 15th, 2005, 08:55 AM
#5
Member
Re: Hyperlink in datagrid?
having two fields in the hyperlink column is rather more difficult and the only way i have got this to work is to use a templatecolumn instead of a hyperlink column and then put the asp:hyperlink inside it like so:
VB Code:
<asp:templatecolumn HeaderText="Details" Visible="true">
<itemtemplate>
<asp:HyperLink id="HyperLink1" runat="server"
Text="View Info" NavigateUrl='<%# "name.aspx?" + DataBinder.Eval(Container.DataItem,"fieldname1","name={0}") + "&" +DataBinder.Eval(Container.DataItem,"fieldname2","xcde={0}")%>'>
</asp:HyperLink>
</itemtemplate>
</asp:templatecolumn>
you will need to substitute the fieldnames/column names of your datatable that you need picked up for fieldname1 and fieldname2.
This will then give you a URL of this format:
name.aspx?name=xxxx&xcde=yyyyy
-
Aug 15th, 2005, 09:04 PM
#6
Thread Starter
Lively Member
Re: Hyperlink in datagrid?
Basilisk,
thanks again!!!
Last edited by Chowking; Aug 15th, 2005 at 09:37 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|