Datagrid with hyperlink column problem

cheng_sh

Active member
Joined
Feb 18, 2003
Messages
25
Location
KL
Ive a database with table "People" and fiels "ID", "Name", "Adds", ....etc....

Ive a table.aspx page which displays a table of data with "ID" and "Name" fields only.

The table is a datagrid control with "ID" field as my first column and as a hyperlink column.

When I click the "ID" field for a particular row, Id like it to link to an aspx page(moreInfo.aspx) which display additional info (like "Addrs", "Tel. No.", "surname") under this selected ID.

Question: How do I pass this selected/clicked "ID" parameter to my moreInfo.aspx?

Please kindly help me. Thank you.
 
Use a session variable.

ex.

session("id")=id

you can use this session variable throughout your session.

James
 
Thank you for your reply. Now my problem is when I clicked the hyperlink on the "ID" field in the table, I dont know how to assign the selected "ID" to my session variable.

If there is click_event for datagrid, then i can assign it in this event. But there is no click event for datagrid.

Any idea.

Thank you
 
What I would do is not use a hyperlink column. Instead use a Edit command column.

<asp:datagrid id="lstTrips" runat="server" Width="75%" OnEditCommand="lstResults_Edit" Visible="False" AutoGenerateColumns="False" HorizontalAlign="Center">
<HeaderStyle Font-Bold="True" HorizontalAlign="Center"></HeaderStyle>
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Header"></asp:EditCommandColumn>...</asp:datagrid>

Then on the OnEditCommand="lstResults_Edit" subprocedure use the following code to extract the value of the column.

Public Sub lstResults_Edit(ByVal Source As Object, ByVal E As DataGridCommandEventArgs)


Session("id") = E.Item.Cells(1).Text

Response.Redirect("newForm.aspx")
end sub

James
 
Back
Top