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 19 3373
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 This discussion thread is closed Replies have been disabled for this discussion. Similar topics
9 posts
views
Thread by Leigh Kendall |
last post: by
|
1 post
views
Thread by Mark |
last post: by
|
9 posts
views
Thread by Paul |
last post: by
|
1 post
views
Thread by Nathan Sokalski |
last post: by
|
3 posts
views
Thread by TPhelps |
last post: by
|
3 posts
views
Thread by avanti |
last post: by
|
2 posts
views
Thread by Keith Wilby |
last post: by
|
3 posts
views
Thread by Nathan Sokalski |
last post: by
| | | | | | | | | | | |