473,804 Members | 3,424 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Having a problem with table styles

I can't seem to get my table styles to apply to my DataGrid. In order
for them to apply correctly, what exactly has to be set in the
DataSource and DataMember, and then the DataMapping properties? I keep
trying all different combinations of DataSets, tables, and even
DataViews, but it just isn't working...

I have a DataSet that has the following:
Table1
|_
Table 2
|_
Table 3

Table 3 is the one I am trying to display in the grid..

I've tried for the DataSource the DataSet.Table1 and DataMember
Table2.Table3

Also just DataSet and then in DataMember - Table1.Table2.T able3

Nothing seems to work except doing DataSet and then Table3 for the
DataMember... This is ok, except it displays all the records all the
time, and I only want records for what is selected in Table2....

Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #1
3 1072
Hi,

Use a datareleation and setdatabinding.
Dim ds As DataSet
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

Dim daEmployees As OleDbDataAdapte r

Dim daOrders As OleDbDataAdapte r

Dim daOrderDetails As OleDbDataAdapte r

Dim conn As OleDbConnection

Dim strConn As String

Dim strSQL As String

Dim strItem As String

Dim ctrl As Control

For Each ctrl In Me.Controls

If TypeOf ctrl Is DataGrid Then

Dim dg As DataGrid = ctrl

dg.AllowNavigat ion = False

End If

Next

strConn = "Provider = Microsoft.Jet.O LEDB.4.0;"

strConn &= "Data Source = Northwind.mdb;"

conn = New OleDbConnection (strConn)

ds = New DataSet

daEmployees = New OleDbDataAdapte r("Select * from Employees", conn)

daOrders = New OleDbDataAdapte r("Select * from Orders", conn)

daOrderDetails = New OleDbDataAdapte r("Select * from [Order Details]", conn)

daEmployees.Fil l(ds, "Employee")

daOrders.Fill(d s, "Orders")

daOrderDetails. Fill(ds, "OrderDetai ls")

ds.Relations.Ad d("EmployeeOrde r",
ds.Tables("Empl oyee").Columns( "EmployeeID "), _

ds.Tables("Orde rs").Columns("E mployeeID"))

frm.DataGrid1.S etDataBinding(d s, "Employee.Emplo yeeOrder")

frm.Show()

ds.Relations.Ad d("Order2Detail s", ds.Tables("Orde rs").Columns("O rderID"), _

ds.Tables("Orde rDetails").Colu mns("OrderID"))

dgEmployees.Rea dOnly = True

dgOrders.ReadOn ly = True

dgOrderDetails. ReadOnly = True

dgEmployees.Set DataBinding(ds, "Employee")

dgOrders.SetDat aBinding(ds, "Employee.Emplo yeeOrder")

dgOrderDetails. SetDataBinding( ds, "Employee.Emplo yeeOrder.Order2 Details")

End Sub

Private Sub SetupGrid()

Dim ts As New DataGridTableSt yle

ts.MappingName = "Orders"

Dim dgc As New DataGridTextBox Column

With dgc

..MappingName = "CustomerID "

..HeaderText = "ID"

..Width = 250

End With

ts.GridColumnSt yles.Add(dgc)

dgOrders.TableS tyles.Add(ts)

End Sub

Private Sub SetupGrid2()

Dim ts As New DataGridTableSt yle

ts.MappingName = "OrderDetai ls"

Dim dgc As New DataGridTextBox Column

With dgc

..MappingName = "ProductID"

..HeaderText = "ID"

..Width = 250

End With

ts.ReadOnly = True

ts.GridColumnSt yles.Add(dgc)

dgOrderDetails. TableStyles.Add (ts)

End Sub

Ken

-----------------

"Aaron Smith" <th**********@s mithcentral.net > wrote in message
news:mD******** **********@news svr33.news.prod igy.com...
I can't seem to get my table styles to apply to my DataGrid. In order
for them to apply correctly, what exactly has to be set in the
DataSource and DataMember, and then the DataMapping properties? I keep
trying all different combinations of DataSets, tables, and even
DataViews, but it just isn't working...

I have a DataSet that has the following:
Table1
|_
Table 2
|_
Table 3

Table 3 is the one I am trying to display in the grid..

I've tried for the DataSource the DataSet.Table1 and DataMember
Table2.Table3

Also just DataSet and then in DataMember - Table1.Table2.T able3

Nothing seems to work except doing DataSet and then Table3 for the
DataMember... This is ok, except it displays all the records all the
time, and I only want records for what is selected in Table2....

Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #2
Hi,

Use a datareleation and setdatabinding.
Dim ds As DataSet
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

Dim daEmployees As OleDbDataAdapte r

Dim daOrders As OleDbDataAdapte r

Dim daOrderDetails As OleDbDataAdapte r

Dim conn As OleDbConnection

Dim strConn As String

Dim strSQL As String

Dim strItem As String

Dim ctrl As Control

For Each ctrl In Me.Controls

If TypeOf ctrl Is DataGrid Then

Dim dg As DataGrid = ctrl

dg.AllowNavigat ion = False

End If

Next

strConn = "Provider = Microsoft.Jet.O LEDB.4.0;"

strConn &= "Data Source = Northwind.mdb;"

conn = New OleDbConnection (strConn)

ds = New DataSet

daEmployees = New OleDbDataAdapte r("Select * from Employees", conn)

daOrders = New OleDbDataAdapte r("Select * from Orders", conn)

daOrderDetails = New OleDbDataAdapte r("Select * from [Order Details]", conn)

daEmployees.Fil l(ds, "Employee")

daOrders.Fill(d s, "Orders")

daOrderDetails. Fill(ds, "OrderDetai ls")

ds.Relations.Ad d("EmployeeOrde r",
ds.Tables("Empl oyee").Columns( "EmployeeID "), _

ds.Tables("Orde rs").Columns("E mployeeID"))

frm.DataGrid1.S etDataBinding(d s, "Employee.Emplo yeeOrder")

frm.Show()

ds.Relations.Ad d("Order2Detail s", ds.Tables("Orde rs").Columns("O rderID"), _

ds.Tables("Orde rDetails").Colu mns("OrderID"))

dgEmployees.Rea dOnly = True

dgOrders.ReadOn ly = True

dgOrderDetails. ReadOnly = True

dgEmployees.Set DataBinding(ds, "Employee")

dgOrders.SetDat aBinding(ds, "Employee.Emplo yeeOrder")

dgOrderDetails. SetDataBinding( ds, "Employee.Emplo yeeOrder.Order2 Details")

End Sub

Private Sub SetupGrid()

Dim ts As New DataGridTableSt yle

ts.MappingName = "Orders"

Dim dgc As New DataGridTextBox Column

With dgc

..MappingName = "CustomerID "

..HeaderText = "ID"

..Width = 250

End With

ts.GridColumnSt yles.Add(dgc)

dgOrders.TableS tyles.Add(ts)

End Sub

Private Sub SetupGrid2()

Dim ts As New DataGridTableSt yle

ts.MappingName = "OrderDetai ls"

Dim dgc As New DataGridTextBox Column

With dgc

..MappingName = "ProductID"

..HeaderText = "ID"

..Width = 250

End With

ts.ReadOnly = True

ts.GridColumnSt yles.Add(dgc)

dgOrderDetails. TableStyles.Add (ts)

End Sub

Ken

-----------------

"Aaron Smith" <th**********@s mithcentral.net > wrote in message
news:mD******** **********@news svr33.news.prod igy.com...
I can't seem to get my table styles to apply to my DataGrid. In order
for them to apply correctly, what exactly has to be set in the
DataSource and DataMember, and then the DataMapping properties? I keep
trying all different combinations of DataSets, tables, and even
DataViews, but it just isn't working...

I have a DataSet that has the following:
Table1
|_
Table 2
|_
Table 3

Table 3 is the one I am trying to display in the grid..

I've tried for the DataSource the DataSet.Table1 and DataMember
Table2.Table3

Also just DataSet and then in DataMember - Table1.Table2.T able3

Nothing seems to work except doing DataSet and then Table3 for the
DataMember... This is ok, except it displays all the records all the
time, and I only want records for what is selected in Table2....

Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #3
Thats basically how I set it up in the DataSource and DataMember
properties. I found that in order for it to work, I have to first set it
to the tables that are not replated... Ex: DS = DataSet DM = DS.Table3
Then once I do that, the table styles will apply to the grid on the
screen. Then, I can go in and set the DM = DS.Table1.Table 2.Table3 and
it is still applied and works correctly..

This works fine on 2 of 3 grids though. They ALL work fine when the
program is run... However, there is one grid that when I set it to the
proper databinding, the IDE will throw some exceptions when switching
between code and design views. I'm going to create a seperate thread for
this problem I think, because I don't think it's really a table style
problem anymore, I think there is something else wrong..

Thanks for the help though, I didn't know you could set the relations in
code like that. I saved the example in case I need it later...

Thanks Again,
Aaron

Ken Tucker [MVP] wrote:
Hi,

Use a datareleation and setdatabinding.

<Cut>

dgEmployees.Set DataBinding(ds, "Employee")

dgOrders.SetDat aBinding(ds, "Employee.Emplo yeeOrder")

dgOrderDetails. SetDataBinding( ds, "Employee.Emplo yeeOrder.Order2 Details")

<Cut>

Ken

-----------------


---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #4

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

Similar topics

3
3653
by: Jaz | last post by:
Is there a reason why IE wont apply styles on table cells? Either I shouldn't do this, I've got an error somewhere, or IE has a bug or doesn't support it. (Opera and Moz render okay) Since I've Googled for a few hours and looked this up on a number of CSS sites and found nothing, I assume I have an error. Note that when I embed the styles into the head I see the same result. Here's the page: http://harbell.net/elcanco/order.html Any...
4
2319
by: Charles Russell | last post by:
I am setting a three column layout within an existing table. The table uses previously devloped code so I am force to use it. I have the following styles defined. <code><!--Preventative insert so code does not get interpreted by mail app --> ..c1 { position:relative; margin-left:0;
7
41738
by: Bob Bedford | last post by:
I've an image in a cell of a table. I've this CSS: ..dbtable{ width: 600px; padding: 0px 0px 0px 0px; margin: 0px 0px 0px 0px; border-collapse: collapse; border: 1px solid #000000;
0
746
by: Aaron Smith | last post by:
I can't seem to get my table styles to apply to my DataGrid. In order for them to apply correctly, what exactly has to be set in the DataSource and DataMember, and then the DataMapping properties? I keep trying all different combinations of DataSets, tables, and even DataViews, but it just isn't working... I have a DataSet that has the following: Table1 |_ Table 2
8
1923
by: Viken Karaguesian | last post by:
Hello all, I'll start with this question: Can I assign an ID *and* a CLASS to a DIV? I am under the impression that you can. I'm having a problem that I can't seem to figure out. Some background info: I'm an amateur who makes sites for fun. I'm creating a website for my son's small school. It's a table-less design. I'm basically using a Container DIV with a Content DIV and a right-floating Sidebar DIV.
0
3215
by: =?Utf-8?B?SGFyZHkgV2FuZw==?= | last post by:
Hi all, I have a web form, and I want to use ModalPopupExtender from Ajax Toolkit. I am using IE 7.0 as browser, VS 2005 and Ajax and Ajax Tool Kit installed. Windows XP Pro. Now I have a very strange problem. With 2nd line of code (DOCTYPE), I can popup modal dialog in middle of screen, BUT all my styles are lost, including modal popup is ugly. If I remove DOCTYPE I can see all my styles, BUT modal
7
1950
by: raknin | last post by:
Hi I have a carousel script. I want to load the carousel with a new set of pictures every time I press a button. The problem that I have that the script append the new pictures to the olds one and the next and previous buttons are added again and again. Please help meto solve the problem. The full html and javascript are attached for your conviniet. HTML ------- <HTML> <HEAD> <META http-equiv="Content-Language" content="en-us">
2
2470
by: davidson1 | last post by:
Hai friends..for menu to use in my website..i found in one website....pl look below website.... http://www.dynamicdrive.com/dynamicindex1/omnislide/index.htm i downloaded 2 files.... menuitems.js mmenu.js
5
3432
by: =?Utf-8?B?R1ROMTcwNzc3?= | last post by:
Hi Guys, It's been a while, I've got a small problem that I could do with your expertise on. As you know (I Think) I build websites for recruitment agencies, part of the website includes a job board facility and for job form entry I used a normal form with a normal textbox, however what I'm finding now is that a lot of recruitment consultants are pasting the job description into the textbox, which when submitted is resulting in most of...
0
9710
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9589
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10329
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7626
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6858
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.