473,503 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridView with a View

Hello,

I work with SQL Server 2005 and a dataset in my VS.NET project. I would
like to use a GridView. Is that possible to use a grid View and
configure his datasource with a View (in SQL Server)?

How can I do that?

Thanks a lot.

Mike
Nov 7 '06 #1
1 1114
JPS
Here is a code sample of how to create a dataset and populate the
gridview

DataSet myDataSet = new DataSet("ds1");
string sql = "Select * from Customer";
SqlConnection myConnection = new SqlConnection(@"Data
Source=MYSqlDB;Integrated Security=SSPI;"Initial Catalog=Northwind");
SqlCommand cmd1 = new SqlCommand(sql);
cmd1.CommandType = CommandType.Text;
myConnection.Open();
cmd1.Connection = myConnection;
SqlDataAdapter sqlDAdapt = new SqlDataAdapter();
sqlDAdapt.SelectCommand=cmd1;
sqlDAdapt.Fill(myDataSet,"Account");
myGridView.DataSource = myDataSet.Tables[0];

Let me know if you have any questions
+

On Nov 7, 6:19 am, Mikaël PLOUHINEC <m...@cerealog.frwrote:
Hello,

I work with SQL Server 2005 and a dataset in my VS.NET project. I would
like to use a GridView. Is that possible to use a grid View and
configure his datasource with a View (in SQL Server)?

How can I do that?

Thanks a lot.

Mike
Nov 7 '06 #2

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

Similar topics

5
6408
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the...
0
2383
by: John Smith | last post by:
ASP.Net 2.0 / C# / IIS 6 I have 2 pages. The master page consists of a tabbed menu created using the Menu and MultiView controls. Something like this: ...
3
14428
by: BartMan | last post by:
Greetings, I have a gridview which is sitting on a multi view control (witin a view), and it is bound to a dataset which I dynamically apply to the control within asp.net page. The problem is...
0
1638
by: John Smith | last post by:
If anyone can help, I would very muchly appreciate it. I have a main page that uses the .net 2.0 menu control with the multiview controls as the menu choices. This works fine. One of the menu...
1
2161
by: syl | last post by:
Hello I am trying to create a "easy to use" gridview with filters (dropdownlist in headers), sorting...and much more.... In order to do that, i prefer to use a objectdatasource (ODS) beacause...
4
26681
by: Tomasz Jastrzebski | last post by:
Hello Everyone, I have a GridView control bound to a plain DataTable object. AutoGenerateEditButton is set to true, Edit button gets displayed, and RowEditing event fires as expected.
12
3782
by: Cindy Lee | last post by:
When I do a sorta on 1 table, then the other table goes back to the original order. What can I set so, it keeps the order of the other current gridview's order. I set all the gridview values...
3
3652
by: Dariusz Tomon | last post by:
Hello, I have GridView in EditItem Template of DetailsView (in normal - read-only mode there is a label). When I'm in edit mode I can select one item from GridView. The main problem is that as...
7
2672
by: Joe Kovac | last post by:
Hi! I have one page with a GridView. Their I can select one item and edit this item on an own page within a DetailsView. After updating the entry I want the user to be able to get back to the...
4
1961
by: svgeorge | last post by:
I NEED TO COLLECT FROM THE GRIDVIEW(DATASELECTED) IN TO A TABLE(SelectedPayment) -------------------------------------------------------------------------------- How TO COLLECT THE ROWS...
0
7089
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7282
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,...
1
6995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5581
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5017
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
389
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.