views:

511

answers:

3

We need to display the result of an SQL SELECT statement on a ASP.NET 3.5 web page. Although there are a number of columns that need to be displayed, only one of the columns needs an editable text box in it... however every record in the result set needs this editable textbox.

I know I can do this manually by building an html table myself, but I was hoping that there was a way to use a data-bound control (GridView? or ListView?) to do it.

Being somewhat new to ASP.NET, I am hoping there is some one out there who has done this.

--Thanks for your help!

A little further clarification....

We need all records to be editable immediately after display - so all records either need to be displayed in edit mode simultaneously - or the regular display mode needs to have an editable text box in it.

A: 

GridView BoundFields have the ReadOnly property which can be used to prevent the field from being edited in Edit mode. Set it to True for all columns that should not be editable.

<asp:boundfield datafield="myNonEditableColumn" Readonly="true" Headertext="My Non-Editable Column"/>
Cerebrus
A: 

Use a GridView and convert the column that you want to be editable to Template. In the ItemTemplate of this field, delete the Label and add a text box.

Add an extra "Save" button outside the GridView, and iterate the GridRows, find the text box (in each row), and use it to update the database.

A: 

Add a template column and then add a text box control instead of a label control

chugh97