I am creating an application in asp.net..I used a grid view to show the datas .. By using the autogenerate columns
I bind the datas to the gridview.. Now i want to make a edit button at the end ..By clicking that the user can edit their details ...
But i need to count the number of columns in a row to make a pop up window to edit the details.. How to find out the number of columns in a autogenerated grid..Number of columns varies depend upon the user..So how to find the number of columns..
You will get the no of columns through like this
int NoOfColumns=GridView1.Rows[0].Cells.Count;
You can find,
How many columns are in gridview with
GridView1.Columns.Count
How many cells are in one row of gridview with
GridView1.Rows[..].Cells.Count
Best Regards
Myra
Related
I have a devexpress grid view in my asp.net web application.Now I can group and select all rows grid wise from header part. I need to select the rows under a group separately without selecting the whole grid rows. Can any one help me on this.
I think this is what you are looking for:
How to implement select/unselect for all rows in a group row
https://www.devexpress.com/Support/Center/Example/Details/E1760
On right side you can run example in browser.
Refer this: ASPxGridView - How to implement select/unselect for all rows in a group row
A similar issue was discussed in the ASPxGridView - How to select multiple rows with a mouse click without pressing the 'Ctrl' key thread. I hope that you find this information helpful.
More references:
ASPxGridView - How to implement select/unselect for all rows in a group row using multiple grouping
How to select data rows and group rows in multiple grouping.
ASPxGridView - AllowSelectByRowClick MultiSelect without holding Ctrl key.
ASPxGridView - Unable to select multiple rows by row click when AllowSelectByRowClick="True"
I have two GridViews. The first grid view's first column is a checkbox.
How can I populate a second grid with the values of the checked rows from the first grid?
For this you need to have a for loop for taking all the rows together and one after another you need to check for the checkbox check property and for all those which are checked you need to add them into another dataset and then you have to assign that dataset to another grid.
You can find detailed narrative here,
http://www.aspsnippets.com/Articles/Transfer-Selected-Rows-from-one-GridView-to-Another-in-Asp.net.aspx
May I know how to show multiple records on the same row in Gridview?
the purpose of these enumerable data bound controls is to show one record/row/object per item template. If you want to show multiple records/rows/objects you will need an intermediate step to aggregate the individual record/row/object together.
then you could bind to the gridview. however, i would recommend the ListView so you can customize the layout however you like.
I am using Devexpress XtraGrid Control, Here I can count the number of rows in footer of grid. but for this I need to set count property of SummeryItem in grid for at least one column. I dont want to do like this.
I want count number of rows in xtraGrid without referring any one column in grid. I just want to show number of rows count. when user will filter that rows, at that time count also need to be changed.
Is there any option to show this number in Group header panel?
I'd use BaseView.RowCount to get the row count and draw it within CustomDrawGroupPanel event.
You can use the customsummarycalculate event to count the number of rows currently shown in the filtered collection and display it in the summary area (generally, I put that text in the summary area of the ID field for the collection I'm using - as I never have a need to put anything else there).
I don't know if this is an update but:
int i = view.SelectedRowsCount;
I have a situation where I'm populating a gridview with a bound data source, and want two additional rows at the very bottom; one to show the sum of values in the columns and one to show the average of values in the columns. I can quite easily calculate these values by aggregating information taken from the rowDataBound event, but don't know how to go about manually adding the additional two rows to the gridview. Any help much appreciated.
You can use the Footer just like you use Headers in gridview. Another solution is use a query in such way:
query 1 : your original query
UNION
query 2 : your query which contains sum
(This applies only if you don't apply paging to your grid)
If it's a single row of information you can use summary footer. See Displaying Summary Information in the GridView's Footer.
(source: asp.net)
If you want two additional rows, you can stuff rows into an IList. At the business logic layer, you can add more rows to the list returned by DAL.