Help a newbie... (DataGrid bound & template columns)

Discussion in 'ASP .Net' started by =?Utf-8?B?RGF2aWQ=?=, Feb 7, 2005.

  1. Hello,

    I have a DataGrid that has a template col with an asp:LinkButton tag in it.

    When the LinkButton is clicked for this row, the onClick handler needs to do
    some things with some various data items from this row and eventually modify
    other data items in the same row before rebinding the whole thing.

    But how do I get at the data fields in the "parent row" of the LinkButton
    that was clicked? What is the syntax?

    Thanks,

    David
     
    =?Utf-8?B?RGF2aWQ=?=, Feb 7, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?RGF2aWQ=?=

    Roy Guest

    OMG. I'm actually posting an "answer" to this ng...not just a question.
    :) It's a first.

    Dave, firstly, you mention using a linkbutton... Why specificly?
    Linking to another page seems to imply other things going on here...

    Secondly, to find out how to gain access to various specific cells in a
    datagrid, research "editing a datagrid," (there are a million sites
    online about it) and look for the Sub where the page is updated. This
    will teach you easily.

    It's not involved. Something like "E.Item.Cells(6).Controls(0)"
    references the 6th cell in the currently selected record.

    Something like "Dim strXYZ As String = E.Item.Cells(6).Text" declares a
    string variable and sets the cell's contents to it.
     
    Roy, Feb 7, 2005
    #2
    1. Advertising

  3. When you use Itemtemplate to bind a control
    like any literal controls, you have to
    get the handle of the control by using FindControl() like this,

    LinkButton l = (LinkButton) e.Item.FindControl("LinkButtonID");

    This will find the control and assign it to the object l, you can do any
    kind of manipulation with the l and that
    will be replicated to the actual control located in
    the page.

    Hope, this helps you.

    Thanks & Regards
    Vadivel Kumar
    http:\\csharpblogs.blogspot.com

    "David" <> wrote in message
    news:...
    > Hello,
    >
    > I have a DataGrid that has a template col with an asp:LinkButton tag in
    > it.
    >
    > When the LinkButton is clicked for this row, the onClick handler needs to
    > do
    > some things with some various data items from this row and eventually
    > modify
    > other data items in the same row before rebinding the whole thing.
    >
    > But how do I get at the data fields in the "parent row" of the LinkButton
    > that was clicked? What is the syntax?
    >
    > Thanks,
    >
    > David
    >
    >
    >
    >
     
    Vadivel Kumar, Feb 10, 2005
    #3
    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. Julie Barnet

    Datagrid bound columns

    Julie Barnet, Dec 2, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    424
    Julie Barnet
    Dec 2, 2003
  2. Dan
    Replies:
    2
    Views:
    3,462
  3. =?Utf-8?B?Sm9u?=

    Datagrid, adding bound columns.

    =?Utf-8?B?Sm9u?=, Feb 15, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    426
    =?Utf-8?B?Sm9u?=
    Feb 15, 2006
  4. Replies:
    1
    Views:
    486
    =?Utf-8?B?U2VyZ2V5IFp1eWV2?=
    Sep 21, 2006
  5. Vinki

    template columns and bound columns in gridview

    Vinki, Apr 25, 2007, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    872
    Vinki
    Apr 25, 2007
Loading...

Share This Page