How to know the selected row in a DataControlField

Discussion in 'ASP .Net Web Controls' started by JamesD, Jan 23, 2007.

  1. JamesD

    JamesD Guest

    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
     
    JamesD, Jan 23, 2007
    #1
    1. Advertising

  2. JamesD

    bhavesh Guest

    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
     
    bhavesh, Jan 23, 2007
    #2
    1. Advertising

  3. JamesD

    JamesD Guest

    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
     
    JamesD, Jan 23, 2007
    #3
  4. JamesD

    bhavesh Guest

    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


    On Jan 23, 9:27 pm, "JamesD" <> 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 -
     
    bhavesh, Jan 24, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U3VyZXNo?=
    Replies:
    1
    Views:
    484
    Saravana
    Nov 22, 2004
  2. Charles Shao
    Replies:
    1
    Views:
    411
    Eliyahu Goldin
    Apr 18, 2005
  3. Want to add row under selected row of gridview

    , Feb 16, 2007, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    340
  4. Marten Engblom

    Custom Control with DataControlField

    Marten Engblom, Feb 18, 2007, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    169
    Marten Engblom
    Feb 18, 2007
  5. Andries

    I know, I know, I don't know

    Andries, Apr 23, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    277
    Gregory Toomey
    Apr 23, 2004
Loading...

Share This Page