Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

labels if columns are not empty

Status
Not open for further replies.

manjulam

Programmer
Feb 27, 2002
103
US
I want to combine add/edit in a datagrid. So i am having 10 empty rows in the datagrid which can be updated to any value so as to simulate insert. I display textboxes in the itemtemplate. What i need to do is :
1.Display labels if the column is not empty with a button to click to go in to edit mode and display the text box.
2. If the column is empty,display the textbox and values can be entered without having to click on the edit button.

Is this possible? Any suggestions?
 
My suggestion would be not to have the add textboxes in the datagrid, but maybe have them under? Perhaps on a seperate page depending on how many of them there are?

In the datagrid itself, I would just display what's already been added to the database and add edit functionality to that (if required).

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
Ya,but i know for sure that there will be only 10 rows at any time in the datagrid. If it is just in edit mode, the user has to click edit each time he wants to insert/update any of the rows. I want to give an easier way to do that.
 
Just have the textboxes under the datagrid. Once the user has filled them all out, they click "add record" or whatever you stick in there and the record is added to the database and then bound to the datagrid:

[DataGrid Start]
+--------------------------+
| Field1 Field2 Field3 |
+--------------------------+
| Col1 Col2 Col3 |
+--------------------------+
[DataGrid End]
TextBox1 TextBox2 TextBox3
[Insert Button]

This will do two things for you:

1) It will be much easier to code. You do not have to deal with onblur() postbacks for field editing (that will probably confuse and irritate the user - it's not really natural)
2) There will be less room for user error. A user will only be able to update a single row at a time and will only be able to insert a single row at any given time. Once the ten record limit has been reached, just set the visibility of the textboxes to false.

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
I figured out a way to do this. Have both labels and textboxes in both itemtemplate and edititemtemplate of the grid. And then in itemdatabound event,control the display of the label and textbox according to what mode the row is in. It works like a charm.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top