Access datagrid's selected row on client side

C

Calvin KD

Hi everyone,
I've got a search screen displayed as a modal dialog screen. On the search
screen I have fields for specifying search criteria and a datagrid for search
results. I'm just looking for a way of returning the selected row's details,
such as an ID, back to the parent window but I don't know how.
Can someone out there show me how or suggest where I can find such
information.
Any suggestion is greatly appreciated.
KD
 
T

Thiruppathi S

Hi Calvin,

For ur need, create an onclick attribute in the datagrid item which fires a
javascript function.
while creating attribute bind the datakey in the js function

Rgds,
Thiruppathi S
 
B

Barry

Hi Calvin,

Maybe this will help:
Create a sub for the IndexChanged event of your datagrid then select the
contents of any cell in that row and assign to data variables.

For example:
Private Sub dgCollection_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles dgCollection.SelectedIndexChanged
Session("GridKey") = dgCollection.SelectedItem.Cells(1).Text
BindDgMapsMines()

End Sub

Good luck.

Barry
 
M

m11533

I'll answer my own question. The result of lots of experimentation indicated
the magic incantation is:

LinkButton lb =
(LinkButton)SiteDataGrid.SelectedItem.FindControl("SiteIDLabel");

-M
 
M

m11533

I'm having a related problem...

I am using a DataGrid with the following column definition:

<asp:TemplateColumn HeaderText="SiteID">
<ItemTemplate>
<asp:LinkButton ID=SiteIDLabel Runat="server" CommandName=Select
Text='<%# DataBinder.Eval(Container, "DataItem.SiteID") %>'>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>

My handler gets called, but every attempt I've made to extract the Text
value of this column in the grid has failed to yield anything useful. I also
am seeing some of the generated HTML (such as a <td> tag) in some of my
attempts.

This is really holding me up, so I appreciate any help you can offer.

-M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top