Editable/Uneditable Gridview rows on condition

Discussion in 'ASP .Net' started by Mike P, Jun 6, 2006.

  1. Mike P

    Mike P Guest

    Is it possible to make an editable gridview so that certain rows are
    editable and other are not editable, dependent upon a value in one of
    the rows columns?


    *** Sent via Developersdex http://www.developersdex.com ***
     
    Mike P, Jun 6, 2006
    #1
    1. Advertising

  2. Mike P

    Winista Guest

    You can try handling the click event on client side and verify the
    conditions. You can return "false" from that event handler to cancel
    postback.

    "Mike P" <> wrote in message
    news:ez%...
    > Is it possible to make an editable gridview so that certain rows are
    > editable and other are not editable, dependent upon a value in one of
    > the rows columns?
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
     
    Winista, Jun 6, 2006
    #2
    1. Advertising

  3. Mike P

    PeterKellner Guest

    On Tue, 06 Jun 2006 08:08:01 -0700, Mike P <>
    wrote:

    >Is it possible to make an editable gridview so that certain rows are
    >editable and other are not editable, dependent upon a value in one of
    >the rows columns?
    >
    >
    >*** Sent via Developersdex http://www.developersdex.com ***


    I would suggest converting the command to a template so you can access
    the link button. Then in your rowcreated event do something like
    this.

    protected void GridView1_RowCreated(object sender,
    GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    int id = (int) DataBinder.Eval(e.Row.DataItem, "id");
    if (id > 1)
    {
    LinkButton lb = (LinkButton)
    e.Row.FindControl("LinkButton1");
    lb.Visible = false;
    }
    }


    }
    Peter Kellner
    http://peterkellner.net
     
    PeterKellner, Jun 6, 2006
    #3
  4. Mike P

    PeterKellner Guest

    On Tue, 06 Jun 2006 08:08:01 -0700, Mike P <>
    wrote:

    >Is it possible to make an editable gridview so that certain rows are
    >editable and other are not editable, dependent upon a value in one of
    >the rows columns?
    >
    >
    >*** Sent via Developersdex http://www.developersdex.com ***


    Make sure you change the command row to a template first. Then this
    code will do the trick:


    protected void GridView1_RowCreated(object sender,
    GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {

    if (e.Row.RowIndex == 0)
    {
    LinkButton lb = (LinkButton)
    e.Row.FindControl("LinkButton1");
    lb.Text = "newtextbutton";
    }
    }


    }
    Peter Kellner
    http://peterkellner.net
     
    PeterKellner, Jun 6, 2006
    #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. Replies:
    0
    Views:
    564
  2. Deshaies
    Replies:
    3
    Views:
    4,616
    Deshaies
    Apr 20, 2004
  3. Ike

    Textarea UnEditable

    Ike, Dec 17, 2003, in forum: HTML
    Replies:
    4
    Views:
    19,881
    sinrize
    Jul 23, 2007
  4. Steve Kershaw

    GridView - how to make a cell uneditable?

    Steve Kershaw, Sep 19, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    870
    Steve Kershaw
    Sep 20, 2007
  5. David C

    Dillema: Editable GridView rows

    David C, Mar 20, 2009, in forum: ASP .Net
    Replies:
    0
    Views:
    336
    David C
    Mar 20, 2009
Loading...

Share This Page