473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DataBind GridView to a DataViewManager in ASP.NET

Simply question
How can I DataBind() a DataViewManager to a GridView in ASP.NET?

Question in Detail
We have a DataSet with relational DataTables (total of 5). We are
generating emails with user specific data, so instead of going back to
the DB for every user, we are getting all data once and filtering on
the DataSet per user (most data overlaps users so this seems like a
good strategy). Our main GridView has child GridView controls that our
bound via CreateChildView(). All is well except for the fact that I
cannot filter on a related DataTable (B) in the DataSet and then
DataBind to related DataTable (A) and the results be filtered due to
the relationship. My only options are 1) using the Select() method on
the DataTable (A) which will not work b/c I cannot bind DataRow[] to a
GridView and 2) setting the RowFilter on DataTable (B)'s DefaultView
then binding DataTable (A)'s DefaultView as this will result in
unfiltered results, making it pointless. So, I have been looking into
the DataViewManager and as I understand it, it is very much like the
DataSet, but for the DataViews instead of DataTables. This is great
because I can simply set the RowFilter on a DataView inside the
DataViewManager (i.e.
ds.DefaultViewManager.DataViewSettings["DataTableName"].RowFilter = "ID
= 100";) and then bind the DataViewManager to the GridView! Oh, if it
were only that easy. I cannot find any good example of how to do this
nor can I get it to work on my own.

This is how it is done in Windows forms:

dataGrid.SetDataBinding(dvm, "DataTableName");

I've tried this in ASP.NET and it was unsuccessful as I receive an
error stating:
"The data source for GridView with id '' did not have any properties or
attributes from which to generate columns. Ensure that your data
source has content.":

gv.DataSource = ds.DefaultViewManager;
gv.DataMember = "DataTableName";
gv.DataBind();
Any help would be greatly appreciated!

Dec 14 '06 #1
0 1367

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rk | last post by:
Hi, I am using a DataViewManager to display the dataset in a datagrid. Once the rowfilter is applied, I would like to know the no. of rows returned so that I can display it on the screen. I...
2
by: jslaybaugh | last post by:
I am trying to bind to a GridView or DetailsView after a callback using the ClientCallback Manager in the new .NET 2.0 framework. See below for the HTML followed by the VB code: <html...
0
by: sreejith.ram | last post by:
I did google & search in this group , but couldnt find any thing related to this. This is my first attempt to connect GridView to a Oracle database via SqlDataSource. I am receving error message...
3
by: K B | last post by:
Hi again, I've narrowed down my problem and am hoping to get some help to get the final answer. Gridview with dynamic child controls loads gv1.Databind calls RowDataBound event fine On the...
3
by: Mark Leistner | last post by:
I am having problems getting a gridview to bind to custom objects under any non-full trust level. I created a test project to verify what I am seeing isn't a side effect of other code in my...
1
by: Mark Olbert | last post by:
I have a GridView as a child control in a custom composite control which is stubornly refusing to databind at design time. I'm convinced I must be missing something about how the databinding process...
3
by: Dave | last post by:
I have an GridView on one page that will open a popup for the selected record. I've been told that there is a way that when the popup record is updated the GridView can be refreshed or Databind. ...
1
by: =?Utf-8?B?cmxt?= | last post by:
I have standard gridview in an updatePanel with an AJAX timer that refreshes the data every 5 seconds by calling the grids DataBind method in the tick event. This works great. However, I have a...
2
by: Andy B | last post by:
I don't know if this is even working or not but here is the problem. I have a gridview that I databound to a dictionary<string, stringcollection: Contract StockContract = new Contract();...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.