473,549 Members | 2,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom hyperlink in a grid row

Here is an example of how to write a custom hyperlink in a grid row.
The hyperlink has 3 querystrings giving the ID a a record in the
database and a date range (from - to).

I'm putting this up here because I had some trouble figuring this out
and there are several examples of people who asked the question but
didn't get an answer.

This uses javascript and the GridView OnRowDataBound event.
<%@ Page Language="C#" %>

<script type="text/javascript">
function InflowDetails(M anagerID)
{
window.location .href = "details.aspx?i d=" + ManagerID + "&df=" +
document.getEle mentById("selDa teFrom").value + "&dt=" +
document.getEle mentById("selDa teTo").value;
}
</script>

<asp:GridView ID="gvManagers " runat="server"
DataKeyNames="M anagerID"
OnRowDataBound= "gvManagers_Row DataBound">
<Columns>
<asp:BoundFie ld HeaderText="Man ager" DataField="Mana gerName"
SortExpression= "ManagerNam e" >
<ItemStyle Width="240px" CssClass="gridH yperText"
ForeColor="blac k" />
</asp:BoundField>
...
...
</Columns>
</asp:GridView>

<script runat="server">

protected void gvManagers_RowD ataBound(object sender,
GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.DataRow)
{
e.Row.Cells[0].Text = "<a href='javascrip t:InflowDetails ("
+ gvManagers.Data Keys[e.Row.DataItemI ndex].Value + ");'>"
+ e.Row.Cells[0].Text + "</a>";
}
}

</script>

Jan 18 '07 #1
0 981

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1321
by: Tom Jorgenson | last post by:
I need to create a custom control that behaves like a HyperLink control EXCEPT where I can get into the events somewhere to programmatically decided whether to actually perform the link request, or to refuse it. Why? Because I want to use these links on forms that may have unsaved changes - and I don't want them to lose the changes by...
2
2615
by: damonf | last post by:
I'm currently trying to add an ASP hyperlink to a template column in a datagrid. The normal hyperlink column doesn't give me the ability to add attributes to the item. In my grid there are four columns. Three are databound to a dataset and one is a template column. I need to be able to access each item in the template column (getting...
2
1606
by: klynn | last post by:
I need to create a datagrid dynamically and add a hyperlink onto one of the columns. So the user sees that columns value and can click on it. But the hyperlink sends a value from another column (which is hidden in the datagrid). Whats the best way to do this?
9
15003
by: Paul | last post by:
Hi I have a data grid with a hyperlink column. the colum has numbers like 00001,000002, ect. Just wondering how to get the text value of the cell as tempstring = datagrid.Items(rownumber).Cells.Item(column number).Text returns a blank string. It seems to work ok for the other columns that are just regular datagrid columns, not hyperlink...
2
2253
by: Jason | last post by:
I have a data grid with a hyperlink column. The hyperlink is created by a class that extracts the link from an XML Document. How can I populate the hyperlink column in the data grid with the value (link) returned from my class method? I have to send the company ticker to the class in order to get the correct link. I tried embedding the...
5
1978
by: CSharpguy | last post by:
How can I create a hyperlink in a datagrid were I'm autogenerating the columns? I need to have a link to the document listed in the grid.
2
2781
by: mdock | last post by:
Hello, I have a javascript grid on my ASP page which displays information about the history of specific units produced in our manufacturing facility. One of the results is the order number on which the unit was shipped. If the unit was not shipped, obviously there is no order number; the default value of this field on the data table is 0. ...
1
1912
by: John | last post by:
Hi I have a grid view bound to an SqlDataSource. One of the fields in grid view is a hyperlink field. How can I set the hyperlink field's navigationurl to the value of a field coming form the underlying SqlDataSource? Thanks Regards
1
4371
by: asharda | last post by:
I have a custom property grid. I am using custom property grid as I do not want the error messages that the propertygrid shows when abphabets are entered in interger fields. The custom property grid doesn't show colloections i.e. if I have a List<Objectthen the Collection is shown but when I click on the "..." button next to it nothing...
0
7520
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7450
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1941
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1059
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.