I know it's possible to change some columns in GridView controls to check boxes and when you are editing certain rows, the cells being hi-lited become text boxes, but supposed I want to add other controls in my gridView. For example: in the image below how would I change the entries of CategoryName to be a dropDown box of possible choices?
[Full size]
Use the TemplateField and define what controls are in your EditItemTemplate.
Read this article as a starting point.
Related
I have a text box control and a Grid view control on my web form. The text box is used to search for specific records in the Grid view. What i would like to do now is that when i clear my text box then i want all the original Grid view values to appear inside the Grid view. Any help please.
On clear button click, add code to bind the grid again.
If you have any particular scenario, please update your query with code
I see a lot of code samples that use template fields for say a button column. However, asp has a ButtonField in gridview columns. What is the difference, if any, between quickly throwing a buttonfield column in a gridview over configuring a templatefield column?
Any pre-built column will be easier to use, and be automatically data bound. A templatefield can contain anything, buttons, 10 different buttons, another gridview, etc etc. So it can be whatever you want, but you need to deal with all the controls inside manually. If you are just looking for a column with one button, stick to the buttonfield control.
i was trying to implement aspxgridview with filteration.i have enabled the "Enable filteration" for the aspx gridview .
but when i try to type some letter in filter text box of the aspx grid view the whole data in the grid view gets disappears.
when i remove the letters in the filter text box of the aspxgridview ,still there is no records in the aspxgridview.
why is the records in the apsxgridview disappears when the filteration occurs in aspxgridview?
I think that you are binding the grid to data at runtime. If so, please try the solution from the Why might paging (sorting, grouping, filtering) not work in the ASPxGridView? article. It should help.
I've got this gridview. The gridview uses TemplateFields as the number of fields in the database's table. What I do next is use an ItemTemplate to present the correct column info.
Now, problems rise when the user click's Edit. Since I can only use EditItemTemplate to edit I am resulted with a control in each column. What I really want is to have a single row with no columns so I can easily style the edit mode (having a table with a different layout for example).
Is this possible? If so, how?
I suspect you will have to create your own specialized class that inherits from GridView and does its own rendering to accomplish this.
You might hack some workaround though... such as manually editing the rendered HTML output or DOM.
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.
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.
Add a template column and then add a text box control instead of a label control
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"/>