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

This is a discussion on How to put a GridView's row in edit mode, programatically? - DOTNET ; 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 ...

+ Reply to Thread
Results 1 to 5 of 5

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

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

    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

  2. Default Re: How to put a GridView's row in edit mode, programatically?

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

    --

    Riki

    <ata@mailinator.com> wrote in message
    news:bc79fa6a-998f-453d-91e6-c37d1372413a@e53g2000hsa.googlegroups.com...
    > 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




  3. Default Re: How to put a GridView's row in edit mode, programatically?

    On Jun 6, 8:43 pm, "Riki" <r...@dontnagme.com> wrote:
    > Just make sure that your linkbutton has the property CommandName="Edit".
    >
    > --
    >
    > Riki
    >
    > <a...@mailinator.com> wrote in message
    >
    > news:bc79fa6a-998f-453d-91e6-c37d1372413a@e53g2000hsa.googlegroups.com...
    >
    > > 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.

  4. Default Re: How to put a GridView's row in edit mode, programatically?

    On Jun 6, 8:43 pm, "Riki" <r...@dontnagme.com> wrote:
    > Just make sure that your linkbutton has the property CommandName="Edit".
    >
    > --
    >
    > Riki
    >
    > <a...@mailinator.com> wrote in message
    >
    > news:bc79fa6a-998f-453d-91e6-c37d1372413a@e53g2000hsa.googlegroups.com...
    >
    > > 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?

  5. Default Re: How to put a GridView's row in edit mode, programatically?

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

    >
    > > --

    >
    > > Riki

    >
    > > <a...@mailinator.com> wrote in message

    >
    > >news:bc79fa6a-998f-453d-91e6-c37d1372413a@e53g2000hsa.googlegroups.com...

    >
    > > > 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?

+ Reply to Thread