How can I set item count value per coloumn in DataList ItemTemplate? - asp.net

I want to set my DataList control to have only 7 items visible in each column after DataBind.
Let's say' if I have 18 items in the data source; DataList should be rendered as 3 colums.
1st column will have first 7 items.
2nd column will have items from 8 to 15
3rd column will have items from 16 to 18
How can I set the item count per column for each itemTemplate?

Take a look onto DataList.RepeatColumns property:
DataList1.RepeatColumns = 3;
DataList1.RepeatDirection = RepeatDirection.Vertical;

It sounds like you're talking about limiting the rows, which you can do in your datasource before you bind.
If you are binding to a DataSet or a DataTable, you can create a DataView and filter the data to a subset of rows choosing the seven that you wish to display.
Or perhaps you're looking to page your data? In that case you'll set your DataList's PageSize to 7. (see this article for more: https://web.archive.org/web/20211020121644/https://www.4guysfromrolla.com/articles/081804-1.aspx)

Related

How to design a gridview or table with datasource having blank first row in which we can search table column in asp.net?

I want to design a grid view or table that gets data from database then i want leave first row blank. when user click in the cells of first row and type in, it shows every data that matches.
You can use textBoxes to query your requested data in gridView and use onTextBoxChanged to update the gridView. Instead of increasing the code you also can do it using Table let's say you have 5 columns on the gridView you make table with 5 columns and 2 rows, the first row you put 1 textBox in each cell, in the second column you use colspan property and set it to 5. Then use the event onTextBoxChanged call the SQL command and query the data on textBox then update the gridView.

Limit rows rendered by DataList

I am using DataList in an ASPX page, the DataSource is a DataTable that contains unknown number of rows. I want to show 9 rows at a time on a page.
How can I tell DataList to take first 1 to 9 rows or 19-27 rows etc., and can we configure page number and page size for DataList?

Restricting number of rows in Datalist

In my asp.net I am using Datalist in that I want to limit row count and want the sort to be in vertical. Let me know how to do this.
Ex: I want my list to be like this
1 4
2 5
3 6
for your first issue, restricting to number of rows is, just pass the required data to datalist and for vertical , use this property RepeatDirection="Vertical"

How to count Number of Rows devexpress xtragrid

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;

Display rows in multiple columns in Asp.net Gridview

By default each row of a Gridview maps to each row in a datatable or dataset attached to its datasource. But what if I want to display these rows in multiple columns. For example if it has 10 rows, 5 rows each should be displayed in 2 columns side by side. Also can I do this with the Infragistics grid. Is this possible?
You can use a DataList control instead. It has a RepeatColumns property that you can define the number of columns you want to display.
In .NET Framework 3.5, there is an even better solution, the ListView control. You can find further information about how to use the ListView control here.
If this is a pure coding exercise, then bind to the RowDataBound event of the Gridview. That way, you can do:
e.Row.Cells(2).Text = e.Row.Cells(1).Text
This would place the text from column 1 in column 2 after it has been pulled from the database. You can also dynamically create columns using a similar method.
Re-reading, I think I misunderstand your problem though.
Can't you just put two identical bound columns one after the other?

Resources