473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Capture hyperlink text property

Joe
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 Page_Load event of page_2. What I
don't know is how to populate the hdnClickedLinkText field on page_1 when the
hyperlink is clicked. I've thought about using AddHandler but there is no
exposed click event for the hyperlink control. I could design a custom class
which inherits from the hyperlink class and implement my own Click event, but
this seems a bit much when a simpler solution may exist.

Does anyone have any other ideas?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
Nov 19 '05 #1
19 3453
is this a standard HREF or does it have a postback? If it's a standard HREF
you will have to pass the call to some clientside code, passing in the text,
and then processing it and redirecting. If it's a postback you can get the
info more easily but more importantly you can do what you want/need with it
then (session value, querystring, etc).

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Joe" wrote:
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 Page_Load event of page_2. What I
don't know is how to populate the hdnClickedLinkText field on page_1 when the
hyperlink is clicked. I've thought about using AddHandler but there is no
exposed click event for the hyperlink control. I could design a custom class
which inherits from the hyperlink class and implement my own Click event, but
this seems a bit much when a simpler solution may exist.

Does anyone have any other ideas?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #2
Joe
Standard HREF; there is no postback. page_1 and page_2 are two different
pages.

Each href looks something like: href="page_2.aspx?q1=value1&q2=value2" where
value1 and value2 change from link to link.

Also, I do not have the option to pass the text property in the querystring.

page_2 merely needs the value of the hyperlink's text. I can handle the
processing once I've got it. I just don't know how to get it.

So, any ideas?

For example, how would you "pass the call to some clientside code, passing
in the text?"

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Curt_C [MVP]" wrote:
is this a standard HREF or does it have a postback? If it's a standard HREF
you will have to pass the call to some clientside code, passing in the text,
and then processing it and redirecting. If it's a postback you can get the
info more easily but more importantly you can do what you want/need with it
then (session value, querystring, etc).

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Joe" wrote:
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 Page_Load event of page_2. What I
don't know is how to populate the hdnClickedLinkText field on page_1 when the
hyperlink is clicked. I've thought about using AddHandler but there is no
exposed click event for the hyperlink control. I could design a custom class
which inherits from the hyperlink class and implement my own Click event, but
this seems a bit much when a simpler solution may exist.

Does anyone have any other ideas?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #3
Hi Joe,

Two solutions:
1. Still use Hyperlink column in the datagrid, but add something in
datagrid_itemDatabound event:

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
HyperLink link = (HyperLink)e.Item.Cells[link_column_index].Controls[0];
link.NavigateUrl += "&text=" + link.Text;
}

Then in page2, you can retrieve it from querystring.

2. Change Hyperlink column to LinkButton. Then you can process in
datagrid_ItemCommand event: pass data to Session, Cookie, or queryString and
redirect to page2.
HTH

Elton Wang

"Joe" wrote:
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 Page_Load event of page_2. What I
don't know is how to populate the hdnClickedLinkText field on page_1 when the
hyperlink is clicked. I've thought about using AddHandler but there is no
exposed click event for the hyperlink control. I could design a custom class
which inherits from the hyperlink class and implement my own Click event, but
this seems a bit much when a simpler solution may exist.

Does anyone have any other ideas?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #4
Joe
Thanks Elton. I can't use the QueryString due to Business Requirements. How
do I cast the Hyperlink column in the datagrid to a link button?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
Hi Joe,

Two solutions:
1. Still use Hyperlink column in the datagrid, but add something in
datagrid_itemDatabound event:

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
HyperLink link = (HyperLink)e.Item.Cells[link_column_index].Controls[0];
link.NavigateUrl += "&text=" + link.Text;
}

Then in page2, you can retrieve it from querystring.

2. Change Hyperlink column to LinkButton. Then you can process in
datagrid_ItemCommand event: pass data to Session, Cookie, or queryString and
redirect to page2.
HTH

Elton Wang

"Joe" wrote:
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 Page_Load event of page_2. What I
don't know is how to populate the hdnClickedLinkText field on page_1 when the
hyperlink is clicked. I've thought about using AddHandler but there is no
exposed click event for the hyperlink control. I could design a custom class
which inherits from the hyperlink class and implement my own Click event, but
this seems a bit much when a simpler solution may exist.

Does anyone have any other ideas?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #5
without postback and without querystring you are limited. I would say try the
javascript call.
add an onClick to the HREF to a javascript function, passing in the text and
URL.
Have the javascript function save this to a session item, then redirect to
the URL.

Plenty of samples of this out there...

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Joe" wrote:
Standard HREF; there is no postback. page_1 and page_2 are two different
pages.

Each href looks something like: href="page_2.aspx?q1=value1&q2=value2" where
value1 and value2 change from link to link.

Also, I do not have the option to pass the text property in the querystring.

page_2 merely needs the value of the hyperlink's text. I can handle the
processing once I've got it. I just don't know how to get it.

So, any ideas?

For example, how would you "pass the call to some clientside code, passing
in the text?"

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Curt_C [MVP]" wrote:
is this a standard HREF or does it have a postback? If it's a standard HREF
you will have to pass the call to some clientside code, passing in the text,
and then processing it and redirecting. If it's a postback you can get the
info more easily but more importantly you can do what you want/need with it
then (session value, querystring, etc).

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Joe" wrote:
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 Page_Load event of page_2. What I
don't know is how to populate the hdnClickedLinkText field on page_1 when the
hyperlink is clicked. I've thought about using AddHandler but there is no
exposed click event for the hyperlink control. I could design a custom class
which inherits from the hyperlink class and implement my own Click event, but
this seems a bit much when a simpler solution may exist.

Does anyone have any other ideas?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #6
Joe
I have been looking at samples for over an hour and haven't found one that
shows how to retrieve the text. Do you know how? The URL is easy; the text
is a mystery....
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Curt_C [MVP]" wrote:
without postback and without querystring you are limited. I would say try the
javascript call.
add an onClick to the HREF to a javascript function, passing in the text and
URL.
Have the javascript function save this to a session item, then redirect to
the URL.

Plenty of samples of this out there...

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Joe" wrote:
Standard HREF; there is no postback. page_1 and page_2 are two different
pages.

Each href looks something like: href="page_2.aspx?q1=value1&q2=value2" where
value1 and value2 change from link to link.

Also, I do not have the option to pass the text property in the querystring.

page_2 merely needs the value of the hyperlink's text. I can handle the
processing once I've got it. I just don't know how to get it.

So, any ideas?

For example, how would you "pass the call to some clientside code, passing
in the text?"

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Curt_C [MVP]" wrote:
is this a standard HREF or does it have a postback? If it's a standard HREF
you will have to pass the call to some clientside code, passing in the text,
and then processing it and redirecting. If it's a postback you can get the
info more easily but more importantly you can do what you want/need with it
then (session value, querystring, etc).

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Joe" wrote:

> 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 Page_Load event of page_2. What I
> don't know is how to populate the hdnClickedLinkText field on page_1 when the
> hyperlink is clicked. I've thought about using AddHandler but there is no
> exposed click event for the hyperlink control. I could design a custom class
> which inherits from the hyperlink class and implement my own Click event, but
> this seems a bit much when a simpler solution may exist.
>
> Does anyone have any other ideas?
>
> TIA,
> --
> Joe
>
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #7
No you can't cast Hyperlink to link button. You should change HyperLinkColumn
to ButtonColumn (ButtonType=LinkButton). Then you can do your logic in
datagrid_ItemCommand event on server-side.

HTH

Elton

"Joe" wrote:
Thanks Elton. I can't use the QueryString due to Business Requirements. How
do I cast the Hyperlink column in the datagrid to a link button?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
Hi Joe,

Two solutions:
1. Still use Hyperlink column in the datagrid, but add something in
datagrid_itemDatabound event:

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
HyperLink link = (HyperLink)e.Item.Cells[link_column_index].Controls[0];
link.NavigateUrl += "&text=" + link.Text;
}

Then in page2, you can retrieve it from querystring.

2. Change Hyperlink column to LinkButton. Then you can process in
datagrid_ItemCommand event: pass data to Session, Cookie, or queryString and
redirect to page2.
HTH

Elton Wang

"Joe" wrote:
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 Page_Load event of page_2. What I
don't know is how to populate the hdnClickedLinkText field on page_1 when the
hyperlink is clicked. I've thought about using AddHandler but there is no
exposed click event for the hyperlink control. I could design a custom class
which inherits from the hyperlink class and implement my own Click event, but
this seems a bit much when a simpler solution may exist.

Does anyone have any other ideas?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #8
you misunderstood.. you have to PASS the text to the function.
In otherwords you need to write the text into the onClick function as well
as to the screen.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Joe" wrote:
I have been looking at samples for over an hour and haven't found one that
shows how to retrieve the text. Do you know how? The URL is easy; the text
is a mystery....
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Curt_C [MVP]" wrote:
without postback and without querystring you are limited. I would say try the
javascript call.
add an onClick to the HREF to a javascript function, passing in the text and
URL.
Have the javascript function save this to a session item, then redirect to
the URL.

Plenty of samples of this out there...

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Joe" wrote:
Standard HREF; there is no postback. page_1 and page_2 are two different
pages.

Each href looks something like: href="page_2.aspx?q1=value1&q2=value2" where
value1 and value2 change from link to link.

Also, I do not have the option to pass the text property in the querystring.

page_2 merely needs the value of the hyperlink's text. I can handle the
processing once I've got it. I just don't know how to get it.

So, any ideas?

For example, how would you "pass the call to some clientside code, passing
in the text?"

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Curt_C [MVP]" wrote:

> is this a standard HREF or does it have a postback? If it's a standard HREF
> you will have to pass the call to some clientside code, passing in the text,
> and then processing it and redirecting. If it's a postback you can get the
> info more easily but more importantly you can do what you want/need with it
> then (session value, querystring, etc).
>
> --
> Curt Christianson
> site: http://www.darkfalz.com
> blog: http://blog.darkfalz.com
>
>
>
> "Joe" wrote:
>
> > 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 Page_Load event of page_2. What I
> > don't know is how to populate the hdnClickedLinkText field on page_1 when the
> > hyperlink is clicked. I've thought about using AddHandler but there is no
> > exposed click event for the hyperlink control. I could design a custom class
> > which inherits from the hyperlink class and implement my own Click event, but
> > this seems a bit much when a simpler solution may exist.
> >
> > Does anyone have any other ideas?
> >
> > TIA,
> > --
> > Joe
> >
> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #9
Joe
Curt,

I did not misunderstand. I can't PASS the text if I can't RETRIEVE the text.

I have tried the following javascript:

function parseHyperlinkId(o) {
alert("Thomas Jefferson was a hack!");
alert(o.text);
alert(o.href);
alert(o.target);
}

Using the following Server side code to link the hyperlink's onClick event
to the javascript:

hLink.Attributes.Add("onClick", "return parseHyperlinkId(this);")

The works fine except that o.text returns "undefined." Do you know why? Do
you know how to retrieve the text from the link? Which property I should
use? Do you know what's wrong with my code?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Curt_C [MVP]" wrote:
you misunderstood.. you have to PASS the text to the function.
In otherwords you need to write the text into the onClick function as well
as to the screen.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Joe" wrote:
I have been looking at samples for over an hour and haven't found one that
shows how to retrieve the text. Do you know how? The URL is easy; the text
is a mystery....
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Curt_C [MVP]" wrote:
without postback and without querystring you are limited. I would say try the
javascript call.
add an onClick to the HREF to a javascript function, passing in the text and
URL.
Have the javascript function save this to a session item, then redirect to
the URL.

Plenty of samples of this out there...

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Joe" wrote:

> Standard HREF; there is no postback. page_1 and page_2 are two different
> pages.
>
> Each href looks something like: href="page_2.aspx?q1=value1&q2=value2" where
> value1 and value2 change from link to link.
>
> Also, I do not have the option to pass the text property in the querystring.
>
> page_2 merely needs the value of the hyperlink's text. I can handle the
> processing once I've got it. I just don't know how to get it.
>
> So, any ideas?
>
> For example, how would you "pass the call to some clientside code, passing
> in the text?"
>
> Thanks,
> --
> Joe
>
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
>
>
> "Curt_C [MVP]" wrote:
>
> > is this a standard HREF or does it have a postback? If it's a standard HREF
> > you will have to pass the call to some clientside code, passing in the text,
> > and then processing it and redirecting. If it's a postback you can get the
> > info more easily but more importantly you can do what you want/need with it
> > then (session value, querystring, etc).
> >
> > --
> > Curt Christianson
> > site: http://www.darkfalz.com
> > blog: http://blog.darkfalz.com
> >
> >
> >
> > "Joe" wrote:
> >
> > > 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 Page_Load event of page_2. What I
> > > don't know is how to populate the hdnClickedLinkText field on page_1 when the
> > > hyperlink is clicked. I've thought about using AddHandler but there is no
> > > exposed click event for the hyperlink control. I could design a custom class
> > > which inherits from the hyperlink class and implement my own Click event, but
> > > this seems a bit much when a simpler solution may exist.
> > >
> > > Does anyone have any other ideas?
> > >
> > > TIA,
> > > --
> > > Joe
> > >
> > > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #10
Joe
Thank you, thank you, thank you, thank you.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
No you can't cast Hyperlink to link button. You should change HyperLinkColumn
to ButtonColumn (ButtonType=LinkButton). Then you can do your logic in
datagrid_ItemCommand event on server-side.

HTH

Elton

"Joe" wrote:
Thanks Elton. I can't use the QueryString due to Business Requirements. How
do I cast the Hyperlink column in the datagrid to a link button?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
Hi Joe,

Two solutions:
1. Still use Hyperlink column in the datagrid, but add something in
datagrid_itemDatabound event:

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
HyperLink link = (HyperLink)e.Item.Cells[link_column_index].Controls[0];
link.NavigateUrl += "&text=" + link.Text;
}

Then in page2, you can retrieve it from querystring.

2. Change Hyperlink column to LinkButton. Then you can process in
datagrid_ItemCommand event: pass data to Session, Cookie, or queryString and
redirect to page2.
HTH

Elton Wang

"Joe" wrote:

> 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 Page_Load event of page_2. What I
> don't know is how to populate the hdnClickedLinkText field on page_1 when the
> hyperlink is clicked. I've thought about using AddHandler but there is no
> exposed click event for the hyperlink control. I could design a custom class
> which inherits from the hyperlink class and implement my own Click event, but
> this seems a bit much when a simpler solution may exist.
>
> Does anyone have any other ideas?
>
> TIA,
> --
> Joe
>
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #11
Joe
Elton,

The ItemCommand is not firing. Here is my code:

Private Sub dgForms_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
dgForms.ItemCommand

hdnFormNumber.Value = CType(e.Item.Cells(0).Controls(0), LinkButton).Text
End Sub

I've had this problem before with the SortCommand, but don't quite know how
to resolve it. Do you have any ideas why this wouldn't fire?

Joe
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
No you can't cast Hyperlink to link button. You should change HyperLinkColumn
to ButtonColumn (ButtonType=LinkButton). Then you can do your logic in
datagrid_ItemCommand event on server-side.

HTH

Elton

"Joe" wrote:
Thanks Elton. I can't use the QueryString due to Business Requirements. How
do I cast the Hyperlink column in the datagrid to a link button?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
Hi Joe,

Two solutions:
1. Still use Hyperlink column in the datagrid, but add something in
datagrid_itemDatabound event:

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
HyperLink link = (HyperLink)e.Item.Cells[link_column_index].Controls[0];
link.NavigateUrl += "&text=" + link.Text;
}

Then in page2, you can retrieve it from querystring.

2. Change Hyperlink column to LinkButton. Then you can process in
datagrid_ItemCommand event: pass data to Session, Cookie, or queryString and
redirect to page2.
HTH

Elton Wang

"Joe" wrote:

> 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 Page_Load event of page_2. What I
> don't know is how to populate the hdnClickedLinkText field on page_1 when the
> hyperlink is clicked. I've thought about using AddHandler but there is no
> exposed click event for the hyperlink control. I could design a custom class
> which inherits from the hyperlink class and implement my own Click event, but
> this seems a bit much when a simpler solution may exist.
>
> Does anyone have any other ideas?
>
> TIA,
> --
> Joe
>
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #12
Check the datagrid's EnableViewState, if it's false, enable it. Disabled
EnableViewState causes datagrid not function properly.

HTH

Elton

"Joe" wrote:
Elton,

The ItemCommand is not firing. Here is my code:

Private Sub dgForms_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
dgForms.ItemCommand

hdnFormNumber.Value = CType(e.Item.Cells(0).Controls(0), LinkButton).Text
End Sub

I've had this problem before with the SortCommand, but don't quite know how
to resolve it. Do you have any ideas why this wouldn't fire?

Joe
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
No you can't cast Hyperlink to link button. You should change HyperLinkColumn
to ButtonColumn (ButtonType=LinkButton). Then you can do your logic in
datagrid_ItemCommand event on server-side.

HTH

Elton

"Joe" wrote:
Thanks Elton. I can't use the QueryString due to Business Requirements. How
do I cast the Hyperlink column in the datagrid to a link button?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:

> Hi Joe,
>
> Two solutions:
> 1. Still use Hyperlink column in the datagrid, but add something in
> datagrid_itemDatabound event:
>
> if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
> ListItemType.AlternatingItem)
> {
> HyperLink link = (HyperLink)e.Item.Cells[link_column_index].Controls[0];
> link.NavigateUrl += "&text=" + link.Text;
> }
>
> Then in page2, you can retrieve it from querystring.
>
> 2. Change Hyperlink column to LinkButton. Then you can process in
> datagrid_ItemCommand event: pass data to Session, Cookie, or queryString and
> redirect to page2.
>
>
> HTH
>
> Elton Wang
>
> "Joe" wrote:
>
> > 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 Page_Load event of page_2. What I
> > don't know is how to populate the hdnClickedLinkText field on page_1 when the
> > hyperlink is clicked. I've thought about using AddHandler but there is no
> > exposed click event for the hyperlink control. I could design a custom class
> > which inherits from the hyperlink class and implement my own Click event, but
> > this seems a bit much when a simpler solution may exist.
> >
> > Does anyone have any other ideas?
> >
> > TIA,
> > --
> > Joe
> >
> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #13
Joe
Elton,

Do you know if disabling the page's viewstate diaables the viewstates of the
controls on teh page?

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
Check the datagrid's EnableViewState, if it's false, enable it. Disabled
EnableViewState causes datagrid not function properly.

HTH

Elton

"Joe" wrote:
Elton,

The ItemCommand is not firing. Here is my code:

Private Sub dgForms_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
dgForms.ItemCommand

hdnFormNumber.Value = CType(e.Item.Cells(0).Controls(0), LinkButton).Text
End Sub

I've had this problem before with the SortCommand, but don't quite know how
to resolve it. Do you have any ideas why this wouldn't fire?

Joe
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
No you can't cast Hyperlink to link button. You should change HyperLinkColumn
to ButtonColumn (ButtonType=LinkButton). Then you can do your logic in
datagrid_ItemCommand event on server-side.

HTH

Elton

"Joe" wrote:

> Thanks Elton. I can't use the QueryString due to Business Requirements. How
> do I cast the Hyperlink column in the datagrid to a link button?
> --
> Joe
>
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
>
>
> "Elton W" wrote:
>
> > Hi Joe,
> >
> > Two solutions:
> > 1. Still use Hyperlink column in the datagrid, but add something in
> > datagrid_itemDatabound event:
> >
> > if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
> > ListItemType.AlternatingItem)
> > {
> > HyperLink link = (HyperLink)e.Item.Cells[link_column_index].Controls[0];
> > link.NavigateUrl += "&text=" + link.Text;
> > }
> >
> > Then in page2, you can retrieve it from querystring.
> >
> > 2. Change Hyperlink column to LinkButton. Then you can process in
> > datagrid_ItemCommand event: pass data to Session, Cookie, or queryString and
> > redirect to page2.
> >
> >
> > HTH
> >
> > Elton Wang
> >
> > "Joe" wrote:
> >
> > > 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 Page_Load event of page_2. What I
> > > don't know is how to populate the hdnClickedLinkText field on page_1 when the
> > > hyperlink is clicked. I've thought about using AddHandler but there is no
> > > exposed click event for the hyperlink control. I could design a custom class
> > > which inherits from the hyperlink class and implement my own Click event, but
> > > this seems a bit much when a simpler solution may exist.
> > >
> > > Does anyone have any other ideas?
> > >
> > > TIA,
> > > --
> > > Joe
> > >
> > > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #14
Joe
EnableViewState is on. Any other ideas?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
Check the datagrid's EnableViewState, if it's false, enable it. Disabled
EnableViewState causes datagrid not function properly.

HTH

Elton

"Joe" wrote:
Elton,

The ItemCommand is not firing. Here is my code:

Private Sub dgForms_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
dgForms.ItemCommand

hdnFormNumber.Value = CType(e.Item.Cells(0).Controls(0), LinkButton).Text
End Sub

I've had this problem before with the SortCommand, but don't quite know how
to resolve it. Do you have any ideas why this wouldn't fire?

Joe
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
No you can't cast Hyperlink to link button. You should change HyperLinkColumn
to ButtonColumn (ButtonType=LinkButton). Then you can do your logic in
datagrid_ItemCommand event on server-side.

HTH

Elton

"Joe" wrote:

> Thanks Elton. I can't use the QueryString due to Business Requirements. How
> do I cast the Hyperlink column in the datagrid to a link button?
> --
> Joe
>
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
>
>
> "Elton W" wrote:
>
> > Hi Joe,
> >
> > Two solutions:
> > 1. Still use Hyperlink column in the datagrid, but add something in
> > datagrid_itemDatabound event:
> >
> > if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
> > ListItemType.AlternatingItem)
> > {
> > HyperLink link = (HyperLink)e.Item.Cells[link_column_index].Controls[0];
> > link.NavigateUrl += "&text=" + link.Text;
> > }
> >
> > Then in page2, you can retrieve it from querystring.
> >
> > 2. Change Hyperlink column to LinkButton. Then you can process in
> > datagrid_ItemCommand event: pass data to Session, Cookie, or queryString and
> > redirect to page2.
> >
> >
> > HTH
> >
> > Elton Wang
> >
> > "Joe" wrote:
> >
> > > 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 Page_Load event of page_2. What I
> > > don't know is how to populate the hdnClickedLinkText field on page_1 when the
> > > hyperlink is clicked. I've thought about using AddHandler but there is no
> > > exposed click event for the hyperlink control. I could design a custom class
> > > which inherits from the hyperlink class and implement my own Click event, but
> > > this seems a bit much when a simpler solution may exist.
> > >
> > > Does anyone have any other ideas?
> > >
> > > TIA,
> > > --
> > > Joe
> > >
> > > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #15
Set breakpoints in your code and trace running step by step to see what
happens. It might help.

"Joe" wrote:
EnableViewState is on. Any other ideas?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
Check the datagrid's EnableViewState, if it's false, enable it. Disabled
EnableViewState causes datagrid not function properly.

HTH

Elton

"Joe" wrote:
Elton,

The ItemCommand is not firing. Here is my code:

Private Sub dgForms_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
dgForms.ItemCommand

hdnFormNumber.Value = CType(e.Item.Cells(0).Controls(0), LinkButton).Text
End Sub

I've had this problem before with the SortCommand, but don't quite know how
to resolve it. Do you have any ideas why this wouldn't fire?

Joe
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:

> No you can't cast Hyperlink to link button. You should change HyperLinkColumn
> to ButtonColumn (ButtonType=LinkButton). Then you can do your logic in
> datagrid_ItemCommand event on server-side.
>
> HTH
>
> Elton
>
> "Joe" wrote:
>
> > Thanks Elton. I can't use the QueryString due to Business Requirements. How
> > do I cast the Hyperlink column in the datagrid to a link button?
> > --
> > Joe
> >
> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
> >
> >
> > "Elton W" wrote:
> >
> > > Hi Joe,
> > >
> > > Two solutions:
> > > 1. Still use Hyperlink column in the datagrid, but add something in
> > > datagrid_itemDatabound event:
> > >
> > > if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
> > > ListItemType.AlternatingItem)
> > > {
> > > HyperLink link = (HyperLink)e.Item.Cells[link_column_index].Controls[0];
> > > link.NavigateUrl += "&text=" + link.Text;
> > > }
> > >
> > > Then in page2, you can retrieve it from querystring.
> > >
> > > 2. Change Hyperlink column to LinkButton. Then you can process in
> > > datagrid_ItemCommand event: pass data to Session, Cookie, or queryString and
> > > redirect to page2.
> > >
> > >
> > > HTH
> > >
> > > Elton Wang
> > >
> > > "Joe" wrote:
> > >
> > > > 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 Page_Load event of page_2. What I
> > > > don't know is how to populate the hdnClickedLinkText field on page_1 when the
> > > > hyperlink is clicked. I've thought about using AddHandler but there is no
> > > > exposed click event for the hyperlink control. I could design a custom class
> > > > which inherits from the hyperlink class and implement my own Click event, but
> > > > this seems a bit much when a simpler solution may exist.
> > > >
> > > > Does anyone have any other ideas?
> > > >
> > > > TIA,
> > > > --
> > > > Joe
> > > >
> > > > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #16
Joe
Hi Elton,

The company that I work for requires that page-level ViewState be turned
off. So, just to try it, I turned page-level Viewstate on and the code
works. I have the impression that if the page-level ViewState is turned off,
the individual control's viewstates will not work, regardless of whether or
not they are turned on. Do you know anything about this?

I will see if I can find another solution. I have thought of using
AddHandler to link Sub declarations to the LinkButton's Click event. This
has worked with some success in the past and might provide a solution now.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
Set breakpoints in your code and trace running step by step to see what
happens. It might help.

"Joe" wrote:
EnableViewState is on. Any other ideas?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
Check the datagrid's EnableViewState, if it's false, enable it. Disabled
EnableViewState causes datagrid not function properly.

HTH

Elton

"Joe" wrote:

> Elton,
>
> The ItemCommand is not firing. Here is my code:
>
> Private Sub dgForms_ItemCommand(ByVal source As Object, ByVal e As
> System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
> dgForms.ItemCommand
>
> hdnFormNumber.Value = CType(e.Item.Cells(0).Controls(0), LinkButton).Text
> End Sub
>
> I've had this problem before with the SortCommand, but don't quite know how
> to resolve it. Do you have any ideas why this wouldn't fire?
>
> Joe
> --
> Joe
>
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
>
>
> "Elton W" wrote:
>
> > No you can't cast Hyperlink to link button. You should change HyperLinkColumn
> > to ButtonColumn (ButtonType=LinkButton). Then you can do your logic in
> > datagrid_ItemCommand event on server-side.
> >
> > HTH
> >
> > Elton
> >
> > "Joe" wrote:
> >
> > > Thanks Elton. I can't use the QueryString due to Business Requirements. How
> > > do I cast the Hyperlink column in the datagrid to a link button?
> > > --
> > > Joe
> > >
> > > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
> > >
> > >
> > > "Elton W" wrote:
> > >
> > > > Hi Joe,
> > > >
> > > > Two solutions:
> > > > 1. Still use Hyperlink column in the datagrid, but add something in
> > > > datagrid_itemDatabound event:
> > > >
> > > > if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
> > > > ListItemType.AlternatingItem)
> > > > {
> > > > HyperLink link = (HyperLink)e.Item.Cells[link_column_index].Controls[0];
> > > > link.NavigateUrl += "&text=" + link.Text;
> > > > }
> > > >
> > > > Then in page2, you can retrieve it from querystring.
> > > >
> > > > 2. Change Hyperlink column to LinkButton. Then you can process in
> > > > datagrid_ItemCommand event: pass data to Session, Cookie, or queryString and
> > > > redirect to page2.
> > > >
> > > >
> > > > HTH
> > > >
> > > > Elton Wang
> > > >
> > > > "Joe" wrote:
> > > >
> > > > > 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 Page_Load event of page_2. What I
> > > > > don't know is how to populate the hdnClickedLinkText field on page_1 when the
> > > > > hyperlink is clicked. I've thought about using AddHandler but there is no
> > > > > exposed click event for the hyperlink control. I could design a custom class
> > > > > which inherits from the hyperlink class and implement my own Click event, but
> > > > > this seems a bit much when a simpler solution may exist.
> > > > >
> > > > > Does anyone have any other ideas?
> > > > >
> > > > > TIA,
> > > > > --
> > > > > Joe
> > > > >
> > > > > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #17
You can try another way. When postback, in Page_Load event, re-bind the
datagrid’s data source. The disadvantage is that if you need collect user
changed data from the datagrid, the re-binding will overwriting user changed
data.

HTH

Elton
"Joe" wrote:
Hi Elton,

The company that I work for requires that page-level ViewState be turned
off. So, just to try it, I turned page-level Viewstate on and the code
works. I have the impression that if the page-level ViewState is turned off,
the individual control's viewstates will not work, regardless of whether or
not they are turned on. Do you know anything about this?

I will see if I can find another solution. I have thought of using
AddHandler to link Sub declarations to the LinkButton's Click event. This
has worked with some success in the past and might provide a solution now.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
Set breakpoints in your code and trace running step by step to see what
happens. It might help.

"Joe" wrote:
EnableViewState is on. Any other ideas?
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:

> Check the datagrid's EnableViewState, if it's false, enable it. Disabled
> EnableViewState causes datagrid not function properly.
>
> HTH
>
> Elton
>
> "Joe" wrote:
>
> > Elton,
> >
> > The ItemCommand is not firing. Here is my code:
> >
> > Private Sub dgForms_ItemCommand(ByVal source As Object, ByVal e As
> > System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
> > dgForms.ItemCommand
> >
> > hdnFormNumber.Value = CType(e.Item.Cells(0).Controls(0), LinkButton).Text
> > End Sub
> >
> > I've had this problem before with the SortCommand, but don't quite know how
> > to resolve it. Do you have any ideas why this wouldn't fire?
> >
> > Joe
> > --
> > Joe
> >
> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
> >
> >
> > "Elton W" wrote:
> >
> > > No you can't cast Hyperlink to link button. You should change HyperLinkColumn
> > > to ButtonColumn (ButtonType=LinkButton). Then you can do your logic in
> > > datagrid_ItemCommand event on server-side.
> > >
> > > HTH
> > >
> > > Elton
> > >
> > > "Joe" wrote:
> > >
> > > > Thanks Elton. I can't use the QueryString due to Business Requirements. How
> > > > do I cast the Hyperlink column in the datagrid to a link button?
> > > > --
> > > > Joe
> > > >
> > > > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
> > > >
> > > >
> > > > "Elton W" wrote:
> > > >
> > > > > Hi Joe,
> > > > >
> > > > > Two solutions:
> > > > > 1. Still use Hyperlink column in the datagrid, but add something in
> > > > > datagrid_itemDatabound event:
> > > > >
> > > > > if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
> > > > > ListItemType.AlternatingItem)
> > > > > {
> > > > > HyperLink link = (HyperLink)e.Item.Cells[link_column_index].Controls[0];
> > > > > link.NavigateUrl += "&text=" + link.Text;
> > > > > }
> > > > >
> > > > > Then in page2, you can retrieve it from querystring.
> > > > >
> > > > > 2. Change Hyperlink column to LinkButton. Then you can process in
> > > > > datagrid_ItemCommand event: pass data to Session, Cookie, or queryString and
> > > > > redirect to page2.
> > > > >
> > > > >
> > > > > HTH
> > > > >
> > > > > Elton Wang
> > > > >
> > > > > "Joe" wrote:
> > > > >
> > > > > > 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 Page_Load event of page_2. What I
> > > > > > don't know is how to populate the hdnClickedLinkText field on page_1 when the
> > > > > > hyperlink is clicked. I've thought about using AddHandler but there is no
> > > > > > exposed click event for the hyperlink control. I could design a custom class
> > > > > > which inherits from the hyperlink class and implement my own Click event, but
> > > > > > this seems a bit much when a simpler solution may exist.
> > > > > >
> > > > > > Does anyone have any other ideas?
> > > > > >
> > > > > > TIA,
> > > > > > --
> > > > > > Joe
> > > > > >
> > > > > > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #18
Joe
Elton,

The user can't change any data in the datagrid. We use it solely for
display purposes.

I'm going to post this in today's posts (I am switching back and forth
between too many windows and need to consolidate.). Please feel free to
continue our discussion. I appreciate your suggestions.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
You can try another way. When postback, in Page_Load event, re-bind the
datagrid’s data source. The disadvantage is that if you need collect user
changed data from the datagrid, the re-binding will overwriting user changed
data.

HTH

Elton
"Joe" wrote:
Hi Elton,

The company that I work for requires that page-level ViewState be turned
off. So, just to try it, I turned page-level Viewstate on and the code
works. I have the impression that if the page-level ViewState is turned off,
the individual control's viewstates will not work, regardless of whether or
not they are turned on. Do you know anything about this?

I will see if I can find another solution. I have thought of using
AddHandler to link Sub declarations to the LinkButton's Click event. This
has worked with some success in the past and might provide a solution now.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
Set breakpoints in your code and trace running step by step to see what
happens. It might help.

"Joe" wrote:

> EnableViewState is on. Any other ideas?
> --
> Joe
>
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
>
>
> "Elton W" wrote:
>
> > Check the datagrid's EnableViewState, if it's false, enable it. Disabled
> > EnableViewState causes datagrid not function properly.
> >
> > HTH
> >
> > Elton
> >
> > "Joe" wrote:
> >
> > > Elton,
> > >
> > > The ItemCommand is not firing. Here is my code:
> > >
> > > Private Sub dgForms_ItemCommand(ByVal source As Object, ByVal e As
> > > System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
> > > dgForms.ItemCommand
> > >
> > > hdnFormNumber.Value = CType(e.Item.Cells(0).Controls(0), LinkButton).Text
> > > End Sub
> > >
> > > I've had this problem before with the SortCommand, but don't quite know how
> > > to resolve it. Do you have any ideas why this wouldn't fire?
> > >
> > > Joe
> > > --
> > > Joe
> > >
> > > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
> > >
> > >
> > > "Elton W" wrote:
> > >
> > > > No you can't cast Hyperlink to link button. You should change HyperLinkColumn
> > > > to ButtonColumn (ButtonType=LinkButton). Then you can do your logic in
> > > > datagrid_ItemCommand event on server-side.
> > > >
> > > > HTH
> > > >
> > > > Elton
> > > >
> > > > "Joe" wrote:
> > > >
> > > > > Thanks Elton. I can't use the QueryString due to Business Requirements. How
> > > > > do I cast the Hyperlink column in the datagrid to a link button?
> > > > > --
> > > > > Joe
> > > > >
> > > > > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
> > > > >
> > > > >
> > > > > "Elton W" wrote:
> > > > >
> > > > > > Hi Joe,
> > > > > >
> > > > > > Two solutions:
> > > > > > 1. Still use Hyperlink column in the datagrid, but add something in
> > > > > > datagrid_itemDatabound event:
> > > > > >
> > > > > > if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
> > > > > > ListItemType.AlternatingItem)
> > > > > > {
> > > > > > HyperLink link = (HyperLink)e.Item.Cells[link_column_index].Controls[0];
> > > > > > link.NavigateUrl += "&text=" + link.Text;
> > > > > > }
> > > > > >
> > > > > > Then in page2, you can retrieve it from querystring.
> > > > > >
> > > > > > 2. Change Hyperlink column to LinkButton. Then you can process in
> > > > > > datagrid_ItemCommand event: pass data to Session, Cookie, or queryString and
> > > > > > redirect to page2.
> > > > > >
> > > > > >
> > > > > > HTH
> > > > > >
> > > > > > Elton Wang
> > > > > >
> > > > > > "Joe" wrote:
> > > > > >
> > > > > > > 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 Page_Load event of page_2. What I
> > > > > > > don't know is how to populate the hdnClickedLinkText field on page_1 when the
> > > > > > > hyperlink is clicked. I've thought about using AddHandler but there is no
> > > > > > > exposed click event for the hyperlink control. I could design a custom class
> > > > > > > which inherits from the hyperlink class and implement my own Click event, but
> > > > > > > this seems a bit much when a simpler solution may exist.
> > > > > > >
> > > > > > > Does anyone have any other ideas?
> > > > > > >
> > > > > > > TIA,
> > > > > > > --
> > > > > > > Joe
> > > > > > >
> > > > > > > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #19
Actually, I think once you re-bind datagrid’s data source in postback,
datagrid’s events will work event disabled datagrid viewstate. Anyhow, you
can try.

HTH

Elton

"Joe" wrote:
Elton,

The user can't change any data in the datagrid. We use it solely for
display purposes.

I'm going to post this in today's posts (I am switching back and forth
between too many windows and need to consolidate.). Please feel free to
continue our discussion. I appreciate your suggestions.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:
You can try another way. When postback, in Page_Load event, re-bind the
datagrid’s data source. The disadvantage is that if you need collect user
changed data from the datagrid, the re-binding will overwriting user changed
data.

HTH

Elton
"Joe" wrote:
Hi Elton,

The company that I work for requires that page-level ViewState be turned
off. So, just to try it, I turned page-level Viewstate on and the code
works. I have the impression that if the page-level ViewState is turned off,
the individual control's viewstates will not work, regardless of whether or
not they are turned on. Do you know anything about this?

I will see if I can find another solution. I have thought of using
AddHandler to link Sub declarations to the LinkButton's Click event. This
has worked with some success in the past and might provide a solution now.
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
"Elton W" wrote:

> Set breakpoints in your code and trace running step by step to see what
> happens. It might help.
>
> "Joe" wrote:
>
> > EnableViewState is on. Any other ideas?
> > --
> > Joe
> >
> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
> >
> >
> > "Elton W" wrote:
> >
> > > Check the datagrid's EnableViewState, if it's false, enable it. Disabled
> > > EnableViewState causes datagrid not function properly.
> > >
> > > HTH
> > >
> > > Elton
> > >
> > > "Joe" wrote:
> > >
> > > > Elton,
> > > >
> > > > The ItemCommand is not firing. Here is my code:
> > > >
> > > > Private Sub dgForms_ItemCommand(ByVal source As Object, ByVal e As
> > > > System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
> > > > dgForms.ItemCommand
> > > >
> > > > hdnFormNumber.Value = CType(e.Item.Cells(0).Controls(0), LinkButton).Text
> > > > End Sub
> > > >
> > > > I've had this problem before with the SortCommand, but don't quite know how
> > > > to resolve it. Do you have any ideas why this wouldn't fire?
> > > >
> > > > Joe
> > > > --
> > > > Joe
> > > >
> > > > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
> > > >
> > > >
> > > > "Elton W" wrote:
> > > >
> > > > > No you can't cast Hyperlink to link button. You should change HyperLinkColumn
> > > > > to ButtonColumn (ButtonType=LinkButton). Then you can do your logic in
> > > > > datagrid_ItemCommand event on server-side.
> > > > >
> > > > > HTH
> > > > >
> > > > > Elton
> > > > >
> > > > > "Joe" wrote:
> > > > >
> > > > > > Thanks Elton. I can't use the QueryString due to Business Requirements. How
> > > > > > do I cast the Hyperlink column in the datagrid to a link button?
> > > > > > --
> > > > > > Joe
> > > > > >
> > > > > > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
> > > > > >
> > > > > >
> > > > > > "Elton W" wrote:
> > > > > >
> > > > > > > Hi Joe,
> > > > > > >
> > > > > > > Two solutions:
> > > > > > > 1. Still use Hyperlink column in the datagrid, but add something in
> > > > > > > datagrid_itemDatabound event:
> > > > > > >
> > > > > > > if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
> > > > > > > ListItemType.AlternatingItem)
> > > > > > > {
> > > > > > > HyperLink link = (HyperLink)e.Item.Cells[link_column_index].Controls[0];
> > > > > > > link.NavigateUrl += "&text=" + link.Text;
> > > > > > > }
> > > > > > >
> > > > > > > Then in page2, you can retrieve it from querystring.
> > > > > > >
> > > > > > > 2. Change Hyperlink column to LinkButton. Then you can process in
> > > > > > > datagrid_ItemCommand event: pass data to Session, Cookie, or queryString and
> > > > > > > redirect to page2.
> > > > > > >
> > > > > > >
> > > > > > > HTH
> > > > > > >
> > > > > > > Elton Wang
> > > > > > >
> > > > > > > "Joe" wrote:
> > > > > > >
> > > > > > > > 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 Page_Load event of page_2. What I
> > > > > > > > don't know is how to populate the hdnClickedLinkText field on page_1 when the
> > > > > > > > hyperlink is clicked. I've thought about using AddHandler but there is no
> > > > > > > > exposed click event for the hyperlink control. I could design a custom class
> > > > > > > > which inherits from the hyperlink class and implement my own Click event, but
> > > > > > > > this seems a bit much when a simpler solution may exist.
> > > > > > > >
> > > > > > > > Does anyone have any other ideas?
> > > > > > > >
> > > > > > > > TIA,
> > > > > > > > --
> > > > > > > > Joe
> > > > > > > >
> > > > > > > > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Nov 19 '05 #20

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

Similar topics

9
by: Leigh Kendall | last post by:
I can't find any issue in the MS KB, but I'm experiencing the following problem which seems to be specific to IE5, and NOT any other version of IE 5.5+ or NN 6+. Issue: I'm using an asp.net...
1
by: Mark | last post by:
Ok this is very odd. I have a hyperlink server control (not a linkbutton) on my .aspx page. When the navigateurl property is set to a file (blah.aspx) in the same directory as the current page,...
9
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 =...
1
by: Nathan Sokalski | last post by:
I am using the ImageUrl property of the Hyperlink control to create a graphical Hyperlink. However, I want to change the size of the image I am using, but the generated HTML places the width/height...
3
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...
3
by: avanti | last post by:
HI, I have a HyperLink in my code. It has a OnClick function defined. I am trying to access the text property of the HyperLink in my JavaScript function. ...
2
by: Keith Wilby | last post by:
I have a personnel database with a hyperlink field which contains the path to a mugshot. I was thinking of combining the hyperlink field with the surname field by putting the surname in the...
3
by: Nathan Sokalski | last post by:
I am using the ImageUrl property of the HyperLink control. My image is large, so I am setting the width/height attributes, but when it renders the width/height attributes are in the <atag rather...
1
by: sivasrec | last post by:
Hi, This is sivakumar from India. Now I am learning to ASP.NET 2.0.. I have a doubt.... I have used in a one hidden field control, 2 label controls, 2 button controls and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...

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.