Merge gridview header or merge sub headers of grid view - c#

I know there is possibility to merge gridview columns but my requirement is some thing different from that I would like to have my gridview as follows
Is it possible to do and also I would like to bind the string values which i will get in a string array.. I would like to create the grid view dynamically and bind the data as per the strings I have is it possible to do.

I had similar situation and ask question few months back. Pivot table help me to solve the issue. check this out.

Related

Asp.net: alternative for gridview + horizontal accordion that display a table?

I need to make a table with huge data from a database, I've done it very easy with a gridview in asp.net but there is a big problem,I need to customize that table a lot.
I want something like this, with a row with data about a person and the row after with a description of projects he's in, then another row with another person data and so on.
Table:
https://ibb.co/dJmEqw
And when i click/hover on a platform(platform i want to be a accordion propriety/it can be a button too) to display a table in the right or down side.
Table inside the platform's accordion:
Hope you get the idea guys, how can I do this with horizontal table lines, tables in accordions click/hover and databind? I need to take data from database and put it in the tables I described but I don't know if i can do that with asp.net gridviews which automatically generate the rows/columns it needs or is it another method ?
Any idea, advice, code is welcome, thanks!
A GridView is a simple "PowerPoint" solution for simple data models.
If you want more complex things get rid of the GridView and use a Repeater to create your HTML table instead. The Repeater control lets you create the table row tags in the ItemTemplate. You can easily generate two rows for each item in DataSource.
Of course, you need to generate the table cells (columns) manually as well with the Repeater control. Use Literal or Label controls to view the data in the table cells. Use
<%#: DataBinder.Eval(Container.DataItem, "propertyname") %>
to assign the Text properties of the controls.

DataTable columns inside columns or merged row table structure

I've had a Google but I find no answer. You know how say in MS Word, when you insert a table, you can merge the columns of one single row to create a column-less row? Or have say a main header and then more columns inside it? Like so:
Merged Row:
|Column 1|Column 2|Column 3|
|Value|Value|Value|
|Merged Row|
|Value|Value|Value|
God the text formatting is awful on this web-site...and the Header Column example:
|Main Header||Another Main Header|
|Column 1|Column2||Column1|Column2|
I'm trying to achieve this in a written DataTable in C# which is being populated by an array. But I'm interested in changing its structure as one of the above, whichever is possible/easier.
So I've created my DataTable and added normal columns and rows etc. But I'd like to create either a merged row or a main header to display. Instead of having a repeated value in a single column for the values I am getting.
Can someone please provide a quick example on how I could achieve either one of those? Because repeated value will just look ugly.
Cheers.
You're talking about displaying data in a particular way but a
DataTable has nothing to do with display. It is for storage and that's
that. How you display the data is up to you. The same data can be
displayed in innumerable different ways. In a WinForms app, one of the
most common ways to display the contents of a DataTable is with a
DataGridView. You can choose which columns to display and merge cells
in that grid if desired. In short, you're looking in the wrong place
to do what you want to do. It is a presentation issue, not a data
issue. –
jmcilhinney

Creating Tables with Multiple Headers in DataGridView in C#

I would like to create a table with multiple headers using DataGridView in C#. I can create a table. However, I need multiple headers in the table. Attached is the screenshot of the table I would like to create.
Any idea how to do it.
This is the concept regarding DataGrid with in DataGrid.You first have to Bind MasterGrid and then bind Child grids with in Master grid.This link will surely help you :
http://www.codeproject.com/Articles/22928/GridView-within-GridView`

Dynamically Add TemplateField to Details View

I have a grid view that, on selected index, will populate a details view. If the selected index happens to have multiple IP Address's I want to add additional fields to display them. They don't need to be databound since I know the data. I'm using the code below to create the additional template fields. This is done in the Data Binding event.
This works until I select a different row in the grid view, then no data is displayed in the details view. My theory is that it's trying to bind the data but there are a different amount of values returned from the database than controls to put them in. I guess is there an easier way to do this?
// Check for multiple IP
countIP = devicesDetails_CountIP(devicesDataKey);
if (countIP > 1)
{
TemplateField IPAddress2 = new TemplateField();
devicesDetailsView.Fields.Insert(0, IPAddress2);
}
Recently I came across this question, so here is a link that may be of help for future visitors
Create DetailsView from codebehind

Formatting columns inside of an ASP Repeater

I'm using an ASP repeater on my page, and I want it to create a 3 column grid. In my HTML page, I use a class which sets the third column so that it fits. Basically, the first 2 columns have a margin-right of 28px so it spaces them nicely and then the third class removes the margin-right so that the columns fit.
Problem is, when this comes into the repeater, I can't use the third class and I get a 2 column result. Any ideas on how I can overcome this?
Use a <table>. I know, I know, we aren't supposed to use tables anymore, right? If you are displaying tabular data, you should use a table. If it's a "grid", that sounds like tabular data to me. Is it?
I managed to resolve this without the use of a <table>. It turned out that the <form> didn't have enough width, so I amended this and it worked.

Categories

Resources