|
-
Jan 21st, 2008, 10:10 PM
#1
Thread Starter
Hyperactive Member
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.
-
Jan 22nd, 2008, 05:20 AM
#2
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.
-
Jan 22nd, 2008, 10:40 AM
#3
Thread Starter
Hyperactive Member
Re: Editable Datagrid (Cells)
-
Feb 4th, 2008, 05:07 PM
#4
Thread Starter
Hyperactive Member
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
-
Feb 5th, 2008, 05:49 AM
#5
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.
-
Feb 5th, 2008, 01:24 PM
#6
Thread Starter
Hyperactive Member
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
-
Feb 6th, 2008, 01:53 PM
#7
Re: Editable Datagrid (Cells)
 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())
-
Feb 8th, 2008, 11:29 AM
#8
Thread Starter
Hyperactive Member
Re: Editable Datagrid (Cells)
Thanks Mendhak. I have incorporated it successfully.
-
Feb 9th, 2008, 05:22 AM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|