473,320 Members | 1,909 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,320 software developers and data experts.

LinkButton : How to navigate to a child in another page

Hi,

The intended functionality is as follows :

I want the user to be able to click on the LinkButton for an individual row
in a datagrid, server side sub grabs id for item selected, stores in session
& reirects user to new page which retrieves id from session & loads its own
grid accordingly.

Note that I don't want pass info as a parameter tacked on to the url... and
this is why I am not using a hyperlink.

My question(s) are :
(1) what is the syntax in the html to build the template column properly for
the LinkButon to acheive this.
(2) How do I tie this in the server side code and retrieve the item
selected.
(3) Also, Am I doing this the hard way. Is there a better way to pass data &
still avoid user seeing parameters ?

Thanks !

Bazza
Nov 19 '05 #1
1 1854
"Bazza Formez" <ba**********@paradise.net.nz> wrote in message
news:41********@clear.net.nz...
Hi,

The intended functionality is as follows :

I want the user to be able to click on the LinkButton for an individual
row in a datagrid, server side sub grabs id for item selected, stores in
session & reirects user to new page which retrieves id from session &
loads its own grid accordingly.

Note that I don't want pass info as a parameter tacked on to the url...
and this is why I am not using a hyperlink.

My question(s) are :
(1) what is the syntax in the html to build the template column properly
for the LinkButon to acheive this.
(2) How do I tie this in the server side code and retrieve the item
selected.
(3) Also, Am I doing this the hard way. Is there a better way to pass data
& still avoid user seeing parameters ?


1) On one of my forms, I have the following:

<asp:TemplateColumn HeaderText="Buy?"><ItemTemplate>
<asp:LinkButton ID="lnkToShopFor" Runat="server"
CommandName="Toggle">No</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>

This renders as:

<td>
<a id="grdShoppingList_ctl02_lnkToShopFor"
href="javascript:__doPostBack('grdShoppingList$ctl 02$lnkToShopFor','')">No</a>
</td>

2) On the server side, you pick this up in the ItemCommand event of the data
grid. The EventArgs will pass you the DataGridItem which represents this row
in the grid, in the Item property. It will also pass you the CommandName and
CommandArgument properties from the LinkButton. If the ID you want to pass
in Session is the primary key of the DataTable you bound the grid to, and if
you specified the DataKey property of the DataGrid, then the grids DataKeys
property can be indexed by e.Item.ItemIndex to find the primary key for that
row. Otherwise, you can pass the id in the CommandArgument property through
data binding.

3) This it the better way. :-) At base, it stores the values in hidden input
fields and then posts back. The receiving control (in this case, the
LinkButton) raises a PostBack event based on the values it finds in the
hidden fields. The event handler then deals with the event, or, in this
case, bubbles it up to its enclosing control (the DataGrid), for you to
handle in the ItemCommand event.

BTW, the other way to not pass parameters is for the client-side code to set
a cookie, but that's not pretty. The hidden form field method is better, and
letting the LinkButton and DataGrid do it for you is better still!

John Saunders
Nov 19 '05 #2

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

Similar topics

8
by: Matt | last post by:
I want to submit the form to the server without opening another page. When we do the following, it will submit the form data in myform to the IIS, and open page2.asp. <form name="myform"...
6
by: anon | last post by:
Post Forwarding question...... For this control below, <asp:Button runat="server" PostTargetUrl="page2.aspx" /> The Attribute: PostTargetUrl="page2.aspx" Is this PostTargetUrl Attribute...
0
by: nik | last post by:
I have a postback on an aspx-page. In this postback I perform a redirect. The page is quite heavy, so instead of performing a postback I perform a post to another empty page, which then can do the...
2
by: Ricardo | last post by:
How can I navigate to another page via a button, and pass a variable to this next page... How can I do this via that method that I see in other sites that the url goes like this: ...
3
by: jonefer | last post by:
I've written the code to do a search from one page and display the results on another - and then I got stuck (because I'm just beginning) It's amazing how difficult it can be to find something so...
17
by: Rabbit | last post by:
Hi, On my 1st page, i have a function which gets a new ID value and need to transfer to another immediately. which I want to get in 2nd page using Request.form("txtID"), but doesn't work, the...
0
by: shival329 | last post by:
Hi, As we know there are a lot of ways to navigate to the another page such as using Response.Redirect, Server.Transfer,Server.Execute,& using context.handler . In all these cases we want to...
3
by: =?Utf-8?B?Tm9yZW1hYw==?= | last post by:
I have had no luck with the following scenario: One of our requirements for a particular business scenario is to test the existance of a URL before sending the client there. If the URL does not...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.