This probably has a simple answer, but I've been looking all over and can't find anything to suit my needs.
I've been using gridviews to display data, but new customer requirements call for the user to be able to select individual columns, rows, or cells. Does anyone know of a good option?
Thanks.
EDIT:
Essentially, I'm displaying several rows of data, each row comprised of multiple columns. With standard gridviews you can't really select all the data in one column without selecting data from the other columns. I need a way for the user to select one column worth of data so that they can copy the data out.
If you're looking for commercial solution, check out Infragistics NetAdvantage for ASP.NET. Example of grid in action: http://www.infragistics.com/products/aspnet/sample/data-grid/selection-client-events
Related
I'm curious as to how you handle instances where users want to know how to exclude columns that have sensitive data. I know explicitly listing the columns is an option but what do you do when you have tables/views with 50-100+ columns?
Example: Say I have a customer table that has 50 columns, I want to exclude 15 columns from the select as they hold sensitive data. I'm aware of all sensitive columns as I have a separate view that specifies them, is there any options to using this view to dynamically define the columns to select?
Appreciate any suggestions!
One possible solution I looked into was creating violatile tables and dropping the sensitive columns.
I have a DataGrid I'm binding to a DataTable, and displaying three BoundColumns as a result.
I would like to have a fourth column that connects with different data-- for instance, if column #3 in the DataGrid is a UserID, I would like to use that to query against a database and retrieve the user's first name, and display it in the fourth column.
Are there any recommended approaches to this? I'm not a DataGrid expert but should I be looking at a TemplateColumn or something along those lines?
Which event should I hook all this querying to, OnItemDataBound?
The recommended approach is return the user's first name as part of the original query and just use a BoundColumn. If you need to modify data before displaying, then yes you can use a TemplateColumn and the OnItemDataBound event to manipulate your data.
Running queries OnItemDataBound is not something I would ever encourage. So if your grid will show 100 records at once, you want to run 100 extra queries per page load? This is something that if you implement, could possibly run within reason during testing. Once under load though, you'll see have hundreds of extra queries running isn't a good idea... it can just be solved by fixing the original query or maybe making a denormalized table depending on your DB structure and the complexity of your query.
When I ran into similar issue, I went the denormalized table route.
Use a join in your sql statement to get the other value.
I have to give a functionality on one of my pages is like:
I have data which represents data of a row from a table, and table has many columns.
This data has to be edited, and sent back to the server.
I am showing data in a datagrid, which obviously doesnt look good as we always have one row and that too a large row, so user has to use scroll to look for some values.
I want suggestions for this, like what should i use to make it look better and more user friendly.
I could have hard coded things but considering, if tomorrow table schema or xml respnse change it will break.
Any suggestions will be nice.
If I have clearly understood your problem, you have too much information in a row and you would like too be able to see all of your row data in the meantime.
How about creating dynamically, on a row double click by example, a form popup that would display vertically your columns data ?
One of the reports I am creating has dynamic number of columns - a datatable gets returned from the stored procedure, the number of columns depend on the number of items defined in the database (one column for each item, other than some fixed columns).
Is it possible for me to use RDLC report to generate a report in this case? All the calculations are already done int he report, I am looking at RDLC only for the sake of export to excel/pdf and repeating header/footer.
It is possible, but there is no simple solution. Here is a link to a former answer of mine on this topic.
An additional investigation later
Here is an article describing the mentioned report generation with a self generated RDL object model in detail.
From the sounds of it, you want your report to pivot defined items, which can change with respect to various report criteria. If you know all the columns that COULD come back, you could just define your RDL to bind them all but hide the ones that aren't item defined. You would just have to bind the Visible property of the column to a determination of whether the has been defined.
For your Problem,
I guess you can go for matrix instead of tables.
where you can generate rows and columns dynamically according to the data you are getting.
Check here for using of matrix
Use matrix in RDLC whenever your columns are not fixed in datatable.
Visit http://www.gotreportviewer.com/matrices/
Here you'll find use of both table and matrix in RDLC. See yourself which one suits for your requirement.
Not sure how to word the question...
Basically, so far all my SQL stuff has been stored procedures and dumped into a gridview. The odd case where I had to perform an action based on a value (such as highlighting a row green if a certain value was true) were done as the gridview was rendering in one of the overrides.
Now however I have to do something far more complicated - pull three sets of data down, run a series of checks on all three and some date related checks and stuff, then populate a gridview with some of the items.
In logic terms, I want to run three queries, and store the lists of results (presumably in Lists?) then run some logic, then populate the gridview.
Specifically what I don't know how to do is:
Best way of pulling the data, and putting it into a List or other datastructure that lets me easily run through it, and retrieve data based on column (myList.age, or more likely, myList["Age"]).
One I have compared the data, I assume I create a new list that will be put into the gridview... how do I put the contents of a list INTO a gridview? How would I add other stuff such as buttons or checkboxes at the same time?
Any nudge in the right direction would be appreciated! Particularly doing cool stuff with lists and sql (if there is anything cool you can do with them)
There are actually several ways to do this with .Net without using an ORM solution. Instead trying to list all of them here I will link you to an article series that should help you accomplish what you want. The following series of articles is about N-Layer design, and includes answers to the information you are looking for. The first set of 4 articles were created some time ago with ASP.Net 2.0 then the author updated them with an additional six articles using ASP.Net 3.5
http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=476
If you want to avoid having to write SQL query and concentrate on the data instead, go with the Entity Framework. It's quite well integrated with VS. It will connect to your SQL database, you will tell it which tables to import, and it will create a series of classes for you to talk to your database.
Queries are quite easy to do, and they will return lists of objects which should be easy to manipulate and put to a grid later on.
You can create datatables and populate them using the lists that you have generated and then bind your grid using the newly created tables as the datasource.