Results 1 to 9 of 9

Thread: Editable Datagrid (Cells)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Malaysia
    Posts
    345

    Editable Datagrid (Cells)

    Hi!

    I want to have a Datagrid, where , I can edit cells (and not rows) , on clicking at it. When I click on a cell, it should become a dropdown , from where I can choose an item. (There should be no Edit link or a button) On clicking the Update button, it should update all the cells , which were edited. Is this is doable in a datagrid? Will DHTML come into picture. Can anyone please guide me to an appropiate article on this, which could give me a start?

    Thanks.
    Thanks.

  2. #2
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Editable Datagrid (Cells)

    It is quite easy to do.

    http://www.codeproject.com/KB/webfor...viewCells.aspx

    Though it is using GridView, changing it to DataGrid should not be a problem.

    This can be easily done using JS too. In the ItemDataBound of DG, add a JS onclick command on the cell and make it to display the dropdownlist or textbox or whatever.
    Show Appreciation. Rate Posts.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Malaysia
    Posts
    345

    Re: Editable Datagrid (Cells)

    Thanks
    Thanks.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Malaysia
    Posts
    345

    Re: Editable Datagrid (Cells)

    This can be easily done using JS too. In the ItemDataBound of DG, add a JS onclick command on the cell and make it to display the dropdownlist or textbox or whatever.

    Can you please send me an example or an article? That will be a great help.

    Thanks
    Thanks.

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Editable Datagrid (Cells)

    Try this out first, then tell us where you're stuck. There are an infinite number of things you can do in the databound events, so there isn't a code sample for every possibility.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Malaysia
    Posts
    345

    Re: Editable Datagrid (Cells)

    Ok...

    Step 1) - I will have two controls in ItemTemplate. First, to display the data. Second will remain invisible. This will become visible only when I click on the cell.


    Step 2) - Add a JS (bind to the click event of a cell), which diplays my invisible control? Pls help me in this.

    The article says "Within the RowDataBound (ItemDataBound) event each cell of the row is looped through and has a click event added. Is this needed?

    Thanks
    Thanks.

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Editable Datagrid (Cells)

    Quote Originally Posted by sinha
    Ok...

    Step 1) - I will have two controls in ItemTemplate. First, to display the data. Second will remain invisible. This will become visible only when I click on the cell.
    Good.

    Step 2) - Add a JS (bind to the click event of a cell), which diplays my invisible control? Pls help me in this.

    The article says "Within the RowDataBound (ItemDataBound) event each cell of the row is looped through and has a click event added. Is this needed?
    Absolutely needed. In the ItemDataBound event, do something like

    e.Cells[4].Attributes.Add("onClick","document.getElementById('" & hiddenclientid & "').visible = true;");

    Where 4 is the cell number with the hidden element, hiddenclientid is the .ClientID property of the hidden element for that itemtemplate. You need to get this using e.FindControl().

    (It may be e.Item.Cells and e.Item.FindControl())

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Malaysia
    Posts
    345

    Re: Editable Datagrid (Cells)

    Thanks Mendhak. I have incorporated it successfully.
    Thanks.

  9. #9
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Editable Datagrid (Cells)

    Good work! Add [Resolved]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width