I currently have a datagrid with several columns. The first column in the
DataGrid is a HyperLinkColumn . When I select a row, I would like for this
HyperlinkColumn to fire. I have the mouseover colors changing, and I have the
routine, but I can't seem to get the HyperLinkColumn to fire....
Private Sub MyDataGrid_Item DataBound(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles
MyDataGrid.Item DataBound
'turn off highlighting...
If bHighlightDataG rid = False Then
Exit Sub
End If
If ((e.Item.ItemTy pe = ListItemType.Pa ger) Or (e.Item.ItemTyp e =
ListItemType.He ader) Or (e.Item.ItemTyp e = ListItemType.Fo oter)) Then
Exit Sub
End If
If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType =
ListItemType.Al ternatingItem Then
e.Item.Attribut es.Add("onmouse over",
"this.style.bac kgroundColor='" & HighlightColor & "'")
If e.Item.ItemType = ListItemType.Al ternatingItem Then
e.Item.Attribut es.Add("onmouse out",
"this.style.bac kgroundColor='" & AlternatingColo r & "'")
Else
e.Item.Attribut es.Add("onmouse out",
"this.style.bac kgroundColor='" & DefaultColor & "'")
End If
e.Item.Attribut es("onclick") =
Page.GetPostBac kClientHyperlin k(e.Item.Cells( 0).Controls(0), "")
'THIS IS THE SECTION THAT I'M ATTEMPTING TO GET THIS TO WORK.
'IF I CHANGE THE HYPERLINK TO HYPERLINKCOLUMN I GET A SYNTAX
'ERROR.
Dim MYLINK As HyperLink = CType(e.Item.Ce lls(0).Controls (0), HyperLink)
e.Item.Attribut es("onclick") =
Page.GetPostBac kClientHyperlin k(MYLINK, "")
End If
End Sub 4 4407
I got your code to work: http://www.societopia.net/samples/Da..._DataList.aspx by using the
Page.GetPostBac kEventReference on a LinkButton (instead of the
Page.GetPostBac kClientHyperlin k that you used on HyperLinkColumn )
Hope this helps.
--
Phillip Williams http://www.societopia.net http://www.webswapp.com
"sakieboy" wrote: I currently have a datagrid with several columns. The first column in the DataGrid is a HyperLinkColumn . When I select a row, I would like for this HyperlinkColumn to fire. I have the mouseover colors changing, and I have the routine, but I can't seem to get the HyperLinkColumn to fire....
Private Sub MyDataGrid_Item DataBound(ByVal sender As Object, ByVal e As System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles MyDataGrid.Item DataBound 'turn off highlighting... If bHighlightDataG rid = False Then Exit Sub End If
If ((e.Item.ItemTy pe = ListItemType.Pa ger) Or (e.Item.ItemTyp e = ListItemType.He ader) Or (e.Item.ItemTyp e = ListItemType.Fo oter)) Then Exit Sub End If
If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType = ListItemType.Al ternatingItem Then e.Item.Attribut es.Add("onmouse over", "this.style.bac kgroundColor='" & HighlightColor & "'") If e.Item.ItemType = ListItemType.Al ternatingItem Then e.Item.Attribut es.Add("onmouse out", "this.style.bac kgroundColor='" & AlternatingColo r & "'") Else e.Item.Attribut es.Add("onmouse out", "this.style.bac kgroundColor='" & DefaultColor & "'") End If e.Item.Attribut es("onclick") = Page.GetPostBac kClientHyperlin k(e.Item.Cells( 0).Controls(0), "")
'THIS IS THE SECTION THAT I'M ATTEMPTING TO GET THIS TO WORK. 'IF I CHANGE THE HYPERLINK TO HYPERLINKCOLUMN I GET A SYNTAX 'ERROR. Dim MYLINK As HyperLink = CType(e.Item.Ce lls(0).Controls (0), HyperLink) e.Item.Attribut es("onclick") = Page.GetPostBac kClientHyperlin k(MYLINK, "") End If
End Sub
Thanks for your help.
Maybe I'm not explaining this correct, let's say that this is my code
If e.Item.ItemType = ListItemType.Al ternatingItem Then
e.Item.Attribut es.Add("onmouse out",
"this.style.bac kgroundColor='" & AlternatingColo r & "'")
Else
e.Item.Attribut es.Add("onmouse out",
"this.style.bac kgroundColor='" & DefaultColor & "'")
End If
Dim MYLINK As HyperLink = CType(e.Item.Ce lls(0).Controls (0),
HyperLink)
e.Item.Attribut es("onclick") =
Page.GetPostBac kEventReference (MYLINK, "")
When I select any row in the grid (excluding the first column, which has the
link in it), I would like it to fire the link in the first column. My
current code, seems like it's firing the ColumHeader "Edit" (which is the
header for the first column) and re-sorting stuff. i.e. if I select an item
in the datagrid which is in the 6th row, 3rd column, it is not firing the
Hyperlink located in the 6th row 1st column. This hyperlink should actually
take me to another page....
"Phillip Williams" wrote: I got your code to work: http://www.societopia.net/samples/Da..._DataList.aspx by using the Page.GetPostBac kEventReference on a LinkButton (instead of the Page.GetPostBac kClientHyperlin k that you used on HyperLinkColumn )
Hope this helps. -- Phillip Williams http://www.societopia.net http://www.webswapp.com
"sakieboy" wrote:
I currently have a datagrid with several columns. The first column in the DataGrid is a HyperLinkColumn . When I select a row, I would like for this HyperlinkColumn to fire. I have the mouseover colors changing, and I have the routine, but I can't seem to get the HyperLinkColumn to fire....
Private Sub MyDataGrid_Item DataBound(ByVal sender As Object, ByVal e As System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles MyDataGrid.Item DataBound 'turn off highlighting... If bHighlightDataG rid = False Then Exit Sub End If
If ((e.Item.ItemTy pe = ListItemType.Pa ger) Or (e.Item.ItemTyp e = ListItemType.He ader) Or (e.Item.ItemTyp e = ListItemType.Fo oter)) Then Exit Sub End If
If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType = ListItemType.Al ternatingItem Then e.Item.Attribut es.Add("onmouse over", "this.style.bac kgroundColor='" & HighlightColor & "'") If e.Item.ItemType = ListItemType.Al ternatingItem Then e.Item.Attribut es.Add("onmouse out", "this.style.bac kgroundColor='" & AlternatingColo r & "'") Else e.Item.Attribut es.Add("onmouse out", "this.style.bac kgroundColor='" & DefaultColor & "'") End If e.Item.Attribut es("onclick") = Page.GetPostBac kClientHyperlin k(e.Item.Cells( 0).Controls(0), "")
'THIS IS THE SECTION THAT I'M ATTEMPTING TO GET THIS TO WORK. 'IF I CHANGE THE HYPERLINK TO HYPERLINKCOLUMN I GET A SYNTAX 'ERROR. Dim MYLINK As HyperLink = CType(e.Item.Ce lls(0).Controls (0), HyperLink) e.Item.Attribut es("onclick") = Page.GetPostBac kClientHyperlin k(MYLINK, "") End If
End Sub
If you are only interested in jumping to the URL of the Hyperlink then why
are you trying to generate a server postback?
You can instead do this:
e.Item.Attribut es("onclick") = _
"javascript :doc ument.URL='" & _
Ctype(e.Item.Ce lls(0).Controls (0), HyperLink).Navi gateUrL & "';"
e.Item.Attribut es("title") = "Click anywhere on the row to jump to the link
associated with this row"
I did that and put a new example (with the source code) to demonstrate it
at: http://www.societopia.net/Samples/Da...DataList2.aspx
--
Phillip Williams http://www.societopia.net http://www.webswapp.com
"sakieboy" wrote: Thanks for your help.
Maybe I'm not explaining this correct, let's say that this is my code
If e.Item.ItemType = ListItemType.Al ternatingItem Then e.Item.Attribut es.Add("onmouse out", "this.style.bac kgroundColor='" & AlternatingColo r & "'") Else e.Item.Attribut es.Add("onmouse out", "this.style.bac kgroundColor='" & DefaultColor & "'") End If
Dim MYLINK As HyperLink = CType(e.Item.Ce lls(0).Controls (0), HyperLink) e.Item.Attribut es("onclick") = Page.GetPostBac kEventReference (MYLINK, "")
When I select any row in the grid (excluding the first column, which has the link in it), I would like it to fire the link in the first column. My current code, seems like it's firing the ColumHeader "Edit" (which is the header for the first column) and re-sorting stuff. i.e. if I select an item in the datagrid which is in the 6th row, 3rd column, it is not firing the Hyperlink located in the 6th row 1st column. This hyperlink should actually take me to another page....
"Phillip Williams" wrote:
I got your code to work: http://www.societopia.net/samples/Da..._DataList.aspx by using the Page.GetPostBac kEventReference on a LinkButton (instead of the Page.GetPostBac kClientHyperlin k that you used on HyperLinkColumn )
Hope this helps. -- Phillip Williams http://www.societopia.net http://www.webswapp.com
"sakieboy" wrote:
I currently have a datagrid with several columns. The first column in the DataGrid is a HyperLinkColumn . When I select a row, I would like for this HyperlinkColumn to fire. I have the mouseover colors changing, and I have the routine, but I can't seem to get the HyperLinkColumn to fire....
Private Sub MyDataGrid_Item DataBound(ByVal sender As Object, ByVal e As System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles MyDataGrid.Item DataBound 'turn off highlighting... If bHighlightDataG rid = False Then Exit Sub End If
If ((e.Item.ItemTy pe = ListItemType.Pa ger) Or (e.Item.ItemTyp e = ListItemType.He ader) Or (e.Item.ItemTyp e = ListItemType.Fo oter)) Then Exit Sub End If
If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType = ListItemType.Al ternatingItem Then e.Item.Attribut es.Add("onmouse over", "this.style.bac kgroundColor='" & HighlightColor & "'") If e.Item.ItemType = ListItemType.Al ternatingItem Then e.Item.Attribut es.Add("onmouse out", "this.style.bac kgroundColor='" & AlternatingColo r & "'") Else e.Item.Attribut es.Add("onmouse out", "this.style.bac kgroundColor='" & DefaultColor & "'") End If e.Item.Attribut es("onclick") = Page.GetPostBac kClientHyperlin k(e.Item.Cells( 0).Controls(0), "")
'THIS IS THE SECTION THAT I'M ATTEMPTING TO GET THIS TO WORK. 'IF I CHANGE THE HYPERLINK TO HYPERLINKCOLUMN I GET A SYNTAX 'ERROR. Dim MYLINK As HyperLink = CType(e.Item.Ce lls(0).Controls (0), HyperLink) e.Item.Attribut es("onclick") = Page.GetPostBac kClientHyperlin k(MYLINK, "") End If
End Sub
That's exactly what I want, I knew it was in the NavigateURL, but wasn't sure
how to access it......Thanks alot!!!
"Phillip Williams" wrote: If you are only interested in jumping to the URL of the Hyperlink then why are you trying to generate a server postback?
You can instead do this:
e.Item.Attribut es("onclick") = _ "javascript:doc ument.URL='" & _ Ctype(e.Item.Ce lls(0).Controls (0), HyperLink).Navi gateUrL & "';" e.Item.Attribut es("title") = "Click anywhere on the row to jump to the link associated with this row"
I did that and put a new example (with the source code) to demonstrate it at: http://www.societopia.net/Samples/Da...DataList2.aspx
-- Phillip Williams http://www.societopia.net http://www.webswapp.com
"sakieboy" wrote:
Thanks for your help.
Maybe I'm not explaining this correct, let's say that this is my code
If e.Item.ItemType = ListItemType.Al ternatingItem Then e.Item.Attribut es.Add("onmouse out", "this.style.bac kgroundColor='" & AlternatingColo r & "'") Else e.Item.Attribut es.Add("onmouse out", "this.style.bac kgroundColor='" & DefaultColor & "'") End If
Dim MYLINK As HyperLink = CType(e.Item.Ce lls(0).Controls (0), HyperLink) e.Item.Attribut es("onclick") = Page.GetPostBac kEventReference (MYLINK, "")
When I select any row in the grid (excluding the first column, which has the link in it), I would like it to fire the link in the first column. My current code, seems like it's firing the ColumHeader "Edit" (which is the header for the first column) and re-sorting stuff. i.e. if I select an item in the datagrid which is in the 6th row, 3rd column, it is not firing the Hyperlink located in the 6th row 1st column. This hyperlink should actually take me to another page....
"Phillip Williams" wrote:
I got your code to work: http://www.societopia.net/samples/Da..._DataList.aspx by using the Page.GetPostBac kEventReference on a LinkButton (instead of the Page.GetPostBac kClientHyperlin k that you used on HyperLinkColumn )
Hope this helps. -- Phillip Williams http://www.societopia.net http://www.webswapp.com
"sakieboy" wrote:
> I currently have a datagrid with several columns. The first column in the > DataGrid is a HyperLinkColumn . When I select a row, I would like for this > HyperlinkColumn to fire. I have the mouseover colors changing, and I have the > routine, but I can't seem to get the HyperLinkColumn to fire.... > > Private Sub MyDataGrid_Item DataBound(ByVal sender As Object, ByVal e As > System.Web.UI.W ebControls.Data GridItemEventAr gs) Handles > MyDataGrid.Item DataBound > 'turn off highlighting... > If bHighlightDataG rid = False Then > Exit Sub > End If > > If ((e.Item.ItemTy pe = ListItemType.Pa ger) Or (e.Item.ItemTyp e = > ListItemType.He ader) Or (e.Item.ItemTyp e = ListItemType.Fo oter)) Then > Exit Sub > End If > > If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType = > ListItemType.Al ternatingItem Then > e.Item.Attribut es.Add("onmouse over", > "this.style.bac kgroundColor='" & HighlightColor & "'") > If e.Item.ItemType = ListItemType.Al ternatingItem Then > e.Item.Attribut es.Add("onmouse out", > "this.style.bac kgroundColor='" & AlternatingColo r & "'") > Else > e.Item.Attribut es.Add("onmouse out", > "this.style.bac kgroundColor='" & DefaultColor & "'") > End If > e.Item.Attribut es("onclick") = > Page.GetPostBac kClientHyperlin k(e.Item.Cells( 0).Controls(0), "") > > 'THIS IS THE SECTION THAT I'M ATTEMPTING TO GET THIS TO WORK. > 'IF I CHANGE THE HYPERLINK TO HYPERLINKCOLUMN I GET A SYNTAX > 'ERROR. > Dim MYLINK As HyperLink = CType(e.Item.Ce lls(0).Controls (0), HyperLink) > e.Item.Attribut es("onclick") = > Page.GetPostBac kClientHyperlin k(MYLINK, "") > End If > > End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Terry |
last post by:
Hey,
Having somewhat of an issue, I have a datagrid which is giving me issues.
The Datagrid is setup for the user to double click the row, the row is
selected and data within that row populates a form for editing. the problem
is when a user clicks on a cell instead of the whole row, I get an error. My
question is this, is there anyway I can setup the datagrid so when the user
clicks on any cell, the whole row is selected not just that...
|
by: Bruce Pullum |
last post by:
I have a datagrid that I am using a DataView with. All works great for the
sorting of the columns. However, after I sort the column, and then try and
select a data row to edit, the row selected represents the indes of the
actual DataGrid and not the DataView. For example.. Lets say I have 4 rows
of data.. In the 4 rows I have an Appt Num of 1,2,3,4... Each representing
a data row... I sort DESC so the rows display 4,3,2,1... If I...
|
by: Chris Plowman |
last post by:
Hi all,
I was wondering if anyone can help me with a really annoying problem I have
been having. I made a derived datagrid class that will select the row when
a user clicks anywhere on a cell (multi-select without modifier keys). I
got that working fine, but I also wanted to keep rows selected after a sort,
which I do by storing the row's id in an arraylist. The idea was to do the
sort and then go back and re-select the rows with that...
|
by: developer |
last post by:
I have a Windows form that contains a datagrid populated
with a table in my database.
When i load my form i want a particular row in my datagrid
to be selected.
How can i do that
Thanks
|
by: Juan |
last post by:
Do i have to loop trough a datagrid in order to find and select a row just
being inserted? is there any event i can capture in the datagrid to obtain
the inserted row? I need to obtain its position in the datagrid...
Any help is very welcome.
| |
by: Zachary Hilbun |
last post by:
I'm using a DataGrid control in a web form. I can display it using binding
but when I click on any of the items there is no feedback that that row has
been selected. I changed SelectedItemStyle but the changes do not appear
when a row is clicked. What do I need to do to get it to do selection?
===================================================
Zachary Hilbun
Software Consultant http://www.vianova.com
Via Nova OpenGL,...
|
by: Bob Hollness |
last post by:
Hi group. I am a newbie to ASP.NET as you will see from some of the
questions I may ask!
I have a datagrid which I have populated from a database. It works great!
I have added a column, via the Columns dialog box from the properties of the
datagrid, on the left that contains a select button. So now, when you press
the button the whole row is highlighted.
Now, what I want to do is have the user highlight as many rows as they wish...
|
by: Vik |
last post by:
If there are a few Select buttons in a datagrid, is there a way to
distinguish in code which button was clicked?
Thanks.
|
by: CharlesA |
last post by:
Hi folks,
I really need help with the following scenario,
I'm going to describe as well as a I can what the setup is and what I can't
understand
I'm using the framework 1.1 using ASP.net with C#
I have a datagrid that is bound to a datasource (through ADO.net) and all
that works
|
by: Wan |
last post by:
Hi,
I have a test project which contains two simple forms - 1st form
contains datagrid and couple of buttons. First button to populate the
grid with Northwind.Customers records and show 3 columns - CustomerID
|CompanyName| ContactName - works fine.
2nd button to bring up the second form contains a datagrid with
customer records with no sorting or order by. The problem is that when
I select one of the customer records and try to show...
|
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...
| |
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...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |