Click here to Skip to main content
15,906,574 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all. I have a small problem with one of my web pages. I have an asp.net table, i need some of the cells to become editable when a user clicks/double clicks on a cell, and when the cell loses focus the entered amount should be saved to the database. Any help will be much appreciated, thanking you in advance.
Posted

My suggestion would be,

What ever the fields you want to make it as editable, place the textbox itself there and disable them to avoid editing, then with css u can make it look like a normal label.

Bind two javascript events onfocus and onblur to the textbox.

"onfocus" make the textbox editable and apply different style to make the user feel that it is textbox :).

"onblur" get the value from the textbox call a codebehind method using ajax call or pagemethod technique and save.

Thats all it will work. To know more about calling code behind method check this link http://witstuner.blogspot.in/2013/02/different-ways-of-ajax-call-in-asp.html[^]
 
Share this answer
 
Ruwaldo Wrote:
How to make asp tablecell editable on click

Why not using Gridview/Listview? Is there any problem in using gridview/Listview?

Better to go with that. Call a function on rowclick event and make it in edit mode.

--Amit
 
Share this answer
 
Comments
Ruwaldo 1-Mar-13 7:06am    
Its easier for me to use a Asp table and the rest of the project uses table the styling is also easier on Asp Table for me
Asim Mahmood 1-Mar-13 7:18am    
are you creating table dynamically if yes then why you are not using jQuery? it's too easy using jQuery.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900