How to know the selected row in a DataControlField

J

JamesD

Hi.

I'm creating a custom WebControl that extends GridView. This control
loads its columns dinamically reading from a XML configuration file.
Many columns loaded by the control may be a custom DataControlField
filled with an ImageButton.
I'm able to handle the click or the command event generated pressing
the ImageButton, directly in the DataControlField i made, but I would
need to know the corresponding row of the pressed ImageButton and i
cannot do that.

Do anyone of you know if is it possible to do that and how?

Thank you so much in advance.

Matteo
 
B

bhavesh

hi james,

just try to view source of ur page generated.

then u will come to know that how the id of image button is generated.


u can access the client id of image button in itemcommand event.

and from there u can split the client id accordingly to get the index
of row in which image button is clicked.

i had this requirement in my repeater control.

and i have achieved this successfully just today.

so u can do same for Gridview control.

try this and then tell me if u got ans.
 
J

JamesD

Hi bhavesh,

first of all thanks a lot for the fast answer.

I've tried to explore html code generated and i found out the piece of
information
you tell me about.
So I saw that client ID is a sort of $ separated format in wich i could
find the row number
hide in this code 'ct101', but i'm not sure of that.

This could help me, but i would like to spend many time yet to find a
less complex and more clear
solution.

Please, tell me if i misunderstood either what you told me or how the
client ID is composed.

Bye.

bhavesh ha scritto:
 
B

bhavesh

hi James,

I think ur easiest solution is

e.Item.ItemIndex

and e should be like : == > ByVal e As DataGridCommandEventArgs ---
in itemcommand event of datagrid.

after seeing ur last reply i have just performed a test on it.

and i am able to find the index of a row in which button has been
clicked.

sorry for first explaination. but it was customized requirement for me
.. thats why i had not any other way. so I tried that one for my
repeater control.

but now u can try above. i am sure u will get ur ans.

bye
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top