How to put a GridView's row in edit mode, programatically?

Discussion in 'ASP .Net' started by ata@mailinator.com, Jun 6, 2008.

  1. Guest

    Hi folks,
    I've got a LinkButton that's being added to the GridView under certain
    circumstances, conditionally.
    Whenever the link is clicked, I would like to put the row (that
    contains the link) in edit mode.
    Please note that I'm trying to do this dynamically, in the run-time.

    Any help would be highly appreciated,

    Thanks
    Jack
    , Jun 6, 2008
    #1
    1. Advertising

  2. Riki Guest

    Just make sure that your linkbutton has the property CommandName="Edit".

    --

    Riki

    <> wrote in message
    news:...
    > Hi folks,
    > I've got a LinkButton that's being added to the GridView under certain
    > circumstances, conditionally.
    > Whenever the link is clicked, I would like to put the row (that
    > contains the link) in edit mode.
    > Please note that I'm trying to do this dynamically, in the run-time.
    >
    > Any help would be highly appreciated,
    >
    > Thanks
    > Jack
    Riki, Jun 6, 2008
    #2
    1. Advertising

  3. Guest

    On Jun 6, 8:43 pm, "Riki" <> wrote:
    > Just make sure that your linkbutton has the property CommandName="Edit".
    >
    > --
    >
    > Riki
    >
    > <> wrote in message
    >
    > news:...
    >
    > > Hi folks,
    > > I've got a LinkButton that's being added to the GridView under certain
    > > circumstances, conditionally.
    > > Whenever the link is clicked, I would like to put the row (that
    > > contains the link) in edit mode.
    > > Please note that I'm trying to do this dynamically, in the run-time.

    >
    > > Any help would be highly appreciated,

    >
    > > Thanks
    > > Jack


    But it doesn't make either.
    , Jun 6, 2008
    #3
  4. Guest

    On Jun 6, 8:43 pm, "Riki" <> wrote:
    > Just make sure that your linkbutton has the property CommandName="Edit".
    >
    > --
    >
    > Riki
    >
    > <> wrote in message
    >
    > news:...
    >
    > > Hi folks,
    > > I've got a LinkButton that's being added to the GridView under certain
    > > circumstances, conditionally.
    > > Whenever the link is clicked, I would like to put the row (that
    > > contains the link) in edit mode.
    > > Please note that I'm trying to do this dynamically, in the run-time.

    >
    > > Any help would be highly appreciated,

    >
    > > Thanks
    > > Jack


    Well, I did so, but it doesn't work yet. Here's the code:

    LinkButton lblOptions = new LinkButton();
    lblOptions.CommandName = "Edit";
    lblOptions.CausesValidation = false;
    lblOptions.ID = "lblOptions" + id;
    lblOptions.Text = String.Format("<span style='margin-left:10px;'></
    span>{0} other options", total);
    lblOptions.Style.Add(HtmlTextWriterStyle.Color, "black");
    lblOptions.Style.Add(HtmlTextWriterStyle.FontWeight, "bold");
    lblOptions.Style.Add(HtmlTextWriterStyle.FontSize, "7pt");

    row.Cells[3].Controls.Add(lblOptions);

    Pressing the link doesn't put the row in Edit mode!
    Any idea?
    , Jun 6, 2008
    #4
  5. Guest

    On Jun 6, 9:29 pm, wrote:
    > On Jun 6, 8:43 pm, "Riki" <> wrote:
    >
    >
    >
    > > Just make sure that your linkbutton has the property CommandName="Edit".

    >
    > > --

    >
    > > Riki

    >
    > > <> wrote in message

    >
    > >news:...

    >
    > > > Hi folks,
    > > > I've got a LinkButton that's being added to the GridView under certain
    > > > circumstances, conditionally.
    > > > Whenever the link is clicked, I would like to put the row (that
    > > > contains the link) in edit mode.
    > > > Please note that I'm trying to do this dynamically, in the run-time.

    >
    > > > Any help would be highly appreciated,

    >
    > > > Thanks
    > > > Jack

    >
    > Well, I did so, but it doesn't work yet. Here's the code:
    >
    > LinkButton lblOptions = new LinkButton();
    > lblOptions.CommandName = "Edit";
    > lblOptions.CausesValidation = false;
    > lblOptions.ID = "lblOptions" + id;
    > lblOptions.Text = String.Format("<span style='margin-left:10px;'></
    > span>{0} other options", total);
    > lblOptions.Style.Add(HtmlTextWriterStyle.Color, "black");
    > lblOptions.Style.Add(HtmlTextWriterStyle.FontWeight, "bold");
    > lblOptions.Style.Add(HtmlTextWriterStyle.FontSize, "7pt");
    >
    > row.Cells[3].Controls.Add(lblOptions);
    >
    > Pressing the link doesn't put the row in Edit mode!
    > Any idea?


    WowI Actually find the problem. The link is created based
    e.Row.DataItem, in the RowCreated event handler.
    However, I've just noticed that when the link button is pressed, the
    RowCreated function gets called,
    but this time, e.Row.DataItem is null!!!!!!

    How this can be possible?
    , Jun 6, 2008
    #5
    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. John A Grandy

    config GridView so row shows in edit mode

    John A Grandy, Feb 17, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    3,889
    Andrew Robinson
    Feb 17, 2006
  2. misiek
    Replies:
    3
    Views:
    47,149
    misiek
    Mar 23, 2006
  3. =?Utf-8?B?R2VyaGFyZA==?=

    gridview row programatically set to edit mode

    =?Utf-8?B?R2VyaGFyZA==?=, Sep 29, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    14,854
    =?Utf-8?B?R2VyaGFyZA==?=
    Sep 29, 2006
  4. jobs at webdos
    Replies:
    1
    Views:
    365
    jobs at webdos
    Oct 12, 2006
  5. Jaime Stuardo

    GridView control enters edit mode when I click Edit link twice

    Jaime Stuardo, Apr 7, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    394
    Jaime Stuardo
    Apr 7, 2006
Loading...

Share This Page