Home All Groups Group Topic Archive Search About

How to know the selected row in a DataControlField

Author
23 Jan 2007 2:25 PM
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

Author
23 Jan 2007 3:24 PM
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.


JamesD wrote:
Show quoteHide quote
> 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
Author
23 Jan 2007 4:27 PM
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:

Show quoteHide quote
> 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.
>
>
> JamesD wrote:
> > 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
Author
24 Jan 2007 6:01 AM
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


Show quoteHide quote
On Jan 23, 9:27 pm, "JamesD" <matteo.font***@gmail.com> wrote:
> 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:
>
>
>
> > 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.
>
> > JamesD wrote:
> > > 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- Hide quoted text -- Show quoted text -