|
-
Feb 10th, 2007, 04:30 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [02/03] Datagrid column Count return 0 always ...
Hi all,
I have bind datagrid dynamically through coding .. it display 2 columns at runtime.
Now i want to make the First column align Right while second to Left.
So i tried to solve it using
VB Code:
DataGrid.Columns(0).Style.HorizontalAlignment = .....Right
But the problem i face is that when i use
VB Code:
Datagrid1.Datasource = ds.Tables(0)
'Response.Write(Datagrid.Columns.Count)
Datagrid1.Databinding()
Response.Write(Datagrid.Columns.Count)
it always gives 0
I know this problem is due to dynamic column binding. But don't know how to solve it..
Help me URGENT..
I am using .NET 2010 with Windows 7
-
Feb 10th, 2007, 06:48 PM
#2
Re: [02/03] Datagrid column Count return 0 always ...
Could you just get the count off of your ds?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 11th, 2007, 11:59 PM
#3
Thread Starter
Hyperactive Member
Re: [02/03] Datagrid column Count return 0 always ...
ok to be more specific..
VB Code:
DataGrid1.DataSource = ds.Tables(1)
Response.Write(ds.Tables(1).Columns.Count) ' This Return 2
Response.Write(DataGrid1.Columns.Count)' This Return 0
DataGrid1.DataBind()
Response.Write(ds.Tables(1).Columns.Count) ' This Return 2
Response.Write(DataGrid1.Columns.Count) '' This Return 0
I am using Dynamic binding..
I am using .NET 2010 with Windows 7
-
Feb 12th, 2007, 12:06 AM
#4
Re: [02/03] Datagrid column Count return 0 always ...
But as I was saying its easier to just reference your datasets column collection. The columns collection is never used when dynamically generated. 
Automatically generated columns are not added to the Columns collection.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 12th, 2007, 12:37 AM
#5
Thread Starter
Hyperactive Member
Re: [02/03] Datagrid column Count return 0 always ...
** Bump **
Ok i want this ..
1. I want to bind datagrid dynamically
2. After then I want to right align first column of datagrid
Can u tell me how's that possible ?
I am using .NET 2010 with Windows 7
-
Feb 12th, 2007, 03:19 AM
#6
Thread Starter
Hyperactive Member
Re: [02/03] Datagrid column Count return 0 always ...
I understood what Rob want to explain and I did my best to solve this. But Could't do anything to solve this.
I am currently using alternative method from backend.. But still desparate to know the solution.
Come on guys i have to solve this during this 2 hours. plz help me..
I am using .NET 2010 with Windows 7
-
Feb 12th, 2007, 03:57 AM
#7
Thread Starter
Hyperactive Member
Re: [02/03] Datagrid column Count return 0 always ...
Sorry couldn't think of this easy method earlier..
VB Code:
DataGrid1.AutoGenerateColumns = False
DataGrid1.DataSource = ds.Tables(1)
Dim bCol As New BoundColumn
bCol.DataField = "FieldValue"
bCol.ItemStyle.HorizontalAlign = HorizontalAlign.Right
DataGrid1.Columns.Add(bCol)
DataGrid1.DataBind()
Hurrayieeeeee........
I am using .NET 2010 with Windows 7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|