Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 7th, 2007, 02:54 PM
Registered User
 
Join Date: Sep 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to DataGridTextBoxColumn to format the column

I would need to format a column "contact" to display only part of the field from the database, but I got an error like this:
object reference not set to an instance of object.

this is part of my code:
           'create a data adapter
            da = New SqlDataAdapter(strQuery, dbSQLConnection)

            'create a new dataset
            ds = New DataSet
            'fill dataset
            da.Fill(ds)
            DataGrid1.DataSource = ds.DefaultViewManager

           'this is where the problem is
            Dim dgt As DataGridTextBoxColumn = CType (DataGrid1.TableStyles("OrHeader").GridColumnStyle s("contact"), DataGridTextBoxColumn)
            Dim index As Integer
            index = dgt.Format.IndexOf(",")
            dgt.Format.Substring(index)

can anyone tell me where I did wrong? Thank you!

 
Old September 7th, 2007, 03:01 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Where / when exactly does the red code run? Can you show the surrounding code? (for example the event handler setup)

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old September 7th, 2007, 03:32 PM
Registered User
 
Join Date: Sep 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this is from form_load event.

thanks.

 
Old September 7th, 2007, 03:37 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

And what exactly is the code supposed to do? I mean, I don't think you can access individual data items in the page load event after you set the datasource, right?

Shouldn't you use an event that is item based? Or am I overlooking something?

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004





Similar Threads
Thread Thread Starter Forum Replies Last Post
find character % and format column paul20091968 Excel VBA 0 January 29th, 2007 05:45 AM
How can I format datagrid column as xxxxxx2345 Jackxxx ASP.NET 2.0 Basics 1 January 17th, 2007 03:12 PM
Format Datagrid column lamdog ASP.NET 1.0 and 1.1 Basics 4 March 23rd, 2005 09:37 AM
DataGridTextBoxColumn Formating melvik C# 1 June 1st, 2004 03:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.