[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Problem with Datagrid Table Style

Posted on 2006-05-29
2
Medium Priority
?
215 Views
Last Modified: 2011-04-14
Hello: After studying many examples of datagrid table styles on this site and others; I've been working it  this week-end to try to change the format of my datagrid. When I use the following code; the datagrid shows up but has no sign of the new formatting.  I suspect my problem could be with this statement:         ts.MappingName = "ds_payment"  I would have thought that should be dbo_payments since that is the underlying table ; but when I change it to ts.mappingname="dbo_payments" ; I get an error.

Again. The grid works fine; its showing the data without any problem; its just unformated.

Thanks for any help you can provide.

Here is the current code:
--------------------------------------------------------------------------------------------------------------


Dim da_payment As New OleDb.OleDbDataAdapter("select [paymentid] as ID,[PaymentDate] as [Pmt Date], [Paymenttype] as [Pmt Method], [PaymentAmount] as Amt, document, expirationdate as [Exp Date]  from dbo_payments", sConnection)

Dim ds_payment As New DataSet
Dim cm_payment As CurrencyManager



        ' start formatting code

        Dim c As DataGridTextBoxColumn
        Dim ts As New DataGridTableStyle
        Dim ds As DataSet = New DataSet

        da_payment.Fill(ds_payment, "dbo_payments")
        gpayment.DataSource = ds_payment.Tables(0)
        gpayment.SetDataBinding(ds_payment, "dbo_payments")
        ts.MappingName = "ds_payment"




        c = New DataGridTextBoxColumn
        c.MappingName = "New ID"
        c.Width = 50
        c.HeaderText = "YYYYMM"
        c.Alignment = HorizontalAlignment.Left '(Right Or center)
        ts.GridColumnStyles.Add(c)

        c = New DataGridTextBoxColumn
        c.MappingName = "New Pmt Amt"
        c.Width = 50
        c.HeaderText = "Pmt Amt"
        ts.GridColumnStyles.Add(c)

        c = New DataGridTextBoxColumn
        c.MappingName = "New Name"
        c.Width = 200
        c.HeaderText = "Prod Name"
        ts.GridColumnStyles.Add(c)
        gpayment.TableStyles.Clear()
        gpayment.TableStyles.Add(ts)
0
Comment
Question by:sny23vpb
2 Comments
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 400 total points
ID: 16787940
OK  lets try it


Dim da_payment As New OleDb.OleDbDataAdapter("select [paymentid] as ID,[PaymentDate] as [Pmt Date], [Paymenttype] as [Pmt Method], [PaymentAmount] as Amt, document, expirationdate as [Exp Date]  from dbo_payments", sConnection)

Dim ds_payment As New DataSet
Dim c As DataGridTextBoxColumn
        Dim ts As New DataGridTableStyle
        Dim ds As DataSet = New DataSet

        da_payment.Fill(ds_payment, "dbo_payments")
        gpayment.DataSource = ds_payment   '<--- Set Source as Dataset
        gpayment.DataMember =  "dbo_payments"   '<--- Member as the DataTable

        ts.MappingName = "dbo_payments"  '<--- Mapping name as DataTable not Dataset

        c = New DataGridTextBoxColumn
        c.MappingName = "ID"  '<-- The Column Name is ID, select [paymentid] as ID
        c.Width = 50
        c.HeaderText = "YYYYMM"
        c.Alignment = HorizontalAlignment.Left '(Right Or center)
        ts.GridColumnStyles.Add(c)

        c = New DataGridTextBoxColumn
        c.MappingName = "Amt"   '<-- Similarly the Query has column called Amt
        c.Width = 50
        c.HeaderText = "Pmt Amt"
        ts.GridColumnStyles.Add(c)

        c = New DataGridTextBoxColumn
        c.MappingName = "New Name"   '<---There's no Column in your Query called "New Name" So this Column would not show
        c.Width = 200
        c.HeaderText = "Prod Name"
        ts.GridColumnStyles.Add(c)
       
        gpayment.TableStyles.Add(ts)


that's it,
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 100 total points
ID: 16788853
gpayment.DataSource = ds_payment.Tables(0)
ts.MappingName =  ds_payment.Tables(0).TableName

Bob
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question