473,854 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Hit hyperlink and send a column value to the code behind.

Pat
All,

What I want to do:
*************** ****
Click on a hyperlink in the last column in a datagrid, have it grab a
value in the fourth column in the same row and send it to the codehind
into a function that will then put the value into a query and send it
off the database.... and do some stuff with the return.

What I have so far:
*************** *****
I have the first part of the program done, the datagrid is populated
and the last column has the hyperlink.

What code I have:
*************** ***
In the .ASPX
=============
<asp:TemplateCo lumn>
<ItemTemplate >
<asp:HyperLin k id="HyperLink2 " Runat="server"> </asp:HyperLink>
</ItemTemplate>
</asp:TemplateCol umn>

In the code behind - In the Page Load
=============== =============== ========
if(Page.Request["Report"]!=null)
ShowReport();

In the code behind
=============== =====
private void grdReceipts_Ite mDataBound(obje ct sender,
System.Web.UI.W ebControls.Data GridItemEventAr gs e)
{
if((e.Item.Item Type == ListItemType.It em)|| (e.Item.ItemTyp e ==
ListItemType.Al ternatingItem))
{
HyperLink c=(HyperLink)e. Item.FindContro l ("HyperLink2 ");
c.Text="Report" ;
c.NavigateUrl=' javascript:docu ment.getElement ById("hidCurren tTab").value
= "Detail"; window.open('It emAudit.aspx?Re port=True', 'Report', '')'
}
}
Any help is appreciated.

Thanks,
Pat G.
Nov 17 '05 #1
1 6564
Pat,
How about using an asp:LinkButton instead of the hyperlink.

You could do something like this:

protected void dgIrResources_O nItemCreated(Ob ject sender,
DataGridItemEve ntArgs e)
{
if (e.Item.ItemTyp e == ListItemType.It em ||
e.Item.ItemType == ListItemType.Al ternatingItem)
{
LinkButton button = (LinkButton ) e.Item.Cells[0].Controls[0];
button.Attribut es.Add("onclick ",
"return confirm(\"Are you sure you want to delete this document? You
cannot submit an Invoice Request to Accounting without an attached
Reconciliation Document\");");
}
}

What I'm doing is using .Attributes.Add to add a javascript confirm to the
onclick event of the LinkButton.
You could use a stringbuilding to build your javascript

StringBuilder sb = new StringBuilder() ;

sb.Append ( blah blah);

then do:

button.Attribut es.Add("onclick ", sb.ToString());
"Pat" <pg******@52mon keys.com> wrote in message
news:1c******** *************** ***@posting.goo gle.com...
All,

What I want to do:
*************** ****
Click on a hyperlink in the last column in a datagrid, have it grab a
value in the fourth column in the same row and send it to the codehind
into a function that will then put the value into a query and send it
off the database.... and do some stuff with the return.

What I have so far:
*************** *****
I have the first part of the program done, the datagrid is populated
and the last column has the hyperlink.

What code I have:
*************** ***
In the .ASPX
=============
<asp:TemplateCo lumn>
<ItemTemplate >
<asp:HyperLin k id="HyperLink2 " Runat="server"> </asp:HyperLink>
</ItemTemplate>
</asp:TemplateCol umn>

In the code behind - In the Page Load
=============== =============== ========
if(Page.Request["Report"]!=null)
ShowReport();

In the code behind
=============== =====
private void grdReceipts_Ite mDataBound(obje ct sender,
System.Web.UI.W ebControls.Data GridItemEventAr gs e)
{
if((e.Item.Item Type == ListItemType.It em)|| (e.Item.ItemTyp e ==
ListItemType.Al ternatingItem))
{
HyperLink c=(HyperLink)e. Item.FindContro l ("HyperLink2 ");
c.Text="Report" ;
c.NavigateUrl=' javascript:docu ment.getElement ById("hidCurren tTab").value
= "Detail"; window.open('It emAudit.aspx?Re port=True', 'Report', '')'
}
}
Any help is appreciated.

Thanks,
Pat G.

Nov 17 '05 #2

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

Similar topics

9
15038
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 types. Thanks. -- Paul G Software engineer.
4
4247
by: Tomek R. | last post by:
Hello ! This post does'nt regard column hyperlink. I just have single hyperlink and want to create it's NavigateUrl dynamically. This is my test page <form id="Form1" method="post" runat="server"> <asp:HyperLink id="MyHLink" NavigateUrl='<%# geturl("123456") %>'
2
2265
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 method into the NavigateURL property of the data grid (i.e. NavigateUrl="GetCompanyLink(Ticker)")...
19
3565
by: Joe | last post by:
I have an aspx page (referred to here as page_1) with a datagrid whose first column contains hyperlinks. When a user clicks one of these hyperlinks, he will navigate to another aspx page (referred to here as page_2). I need to cache the value of the link's text (hyperlink.text property) so that I can use it in the page_load event of page_2. I've thought of using a hidden field and then calling Request.Form("hdnClickedLinkText") in the...
3
3557
by: TPhelps | last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable datagrid that works. I want to change one of the columns to a hyperlink. The examples I find use a bound column. I can get this to work; however, the column header on the datagrid is not a link/sortable. What am I missing? Thanks in advance.
8
2596
by: Sohan Kamat | last post by:
Hi, I have a webform and I want to create a hyperlink to a text file, so that it opens on internet explorer in a new window. I have added the following <a href="file:///D:/Test/Test.txt" id="hplTest" runat="server" >testhyperlink</a> Now when I click on the hyperlink, nothing is happening. No error. when I open a browser and type file:///D:/Test/Test.txt, the file is opening.
3
3072
by: shapper | last post by:
Hello, In my GridView I have a HyperLink Field where I set the DataNavigateUrlFormaString MyHyperLinkField.DataNavigateUrlFormatString = "~\RSS.ashx?Channel={0}&Culture=" & System.Threading.Thread.CurrentThread.CurrentCulture.ToString() I believe {0} retrieves the value of my datasource column with index 0.
8
1192
by: johnlim20088 | last post by:
Hi, Hi currently i have a datagrid it have 3 column the 1st column I using databind. however, for column 2 and 3, i never using databind, I using datagrid1_onitemdatabound command to manually
4
4136
by: =?Utf-8?B?QW1pciBUb2hpZGk=?= | last post by:
Hi I have a GridView that is displaying master records. Some of these records have child records. I would like to a column to my master GridView such that for each master record that has detail records, it displays a hyperlink that then takes the user to the details page. If a master record doesn't have any children, I just want it to display its ID with no hyperlink.
0
9901
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 usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9751
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11024
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10678
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7079
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5940
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4557
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
2
4153
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3185
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.