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 23rd, 2004, 04:45 AM
Authorized User
 
Join Date: Jun 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to SupaHoopsa Send a message via AIM to SupaHoopsa Send a message via Yahoo to SupaHoopsa
Default Losing Datagrid Content when Adding TableStyle

I have an issue with a datagrid 'losing' it's contents when I add a tablestyle to it.

I have one simple line:

MyDataGrid.TableStyles.Add(MyTableStyle)

When run in debug and put a break point on this line, I can see the contents of the datagrid, i.e. MyDataGrid (0,0) returns a value.

However as soon as I run this line and try doing the MyDataGrid(0,0) again I get the following error:

Run-time exception thrown : System.ArgumentOutOfRangeException - Specified argument was out of the range of valid values.
Parameter name: rowIndex


Has anyone else had this problem?
Any ideas what is going on?

 
Old September 23rd, 2004, 10:58 PM
Authorized User
 
Join Date: Jul 2003
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Kindly Try this one, It worked for me. Call drawGrid before binding data(Sample for Datareader, Delete lines with to use dataset)

#Region "Declarations"
   'Grid
   Dim pDatagrid As DataGridTableStyle = New DataGridTableStyle()
   Dim Col1 As DataGridTextBoxColumn = New DataGridTextBoxColumn() '*
   Dim Col2 As DataGridTextBoxColumn = New DataGridTextBoxColumn() '*
   Dim Col3 As DataGridTextBoxColumn = New DataGridTextBoxColumn() '*
   'Grid Table
   Dim pTable As New DataTable("TeamPlayers") '*
   Dim pRow As DataRow '*
#End Region

Sub DrawGrid()
 DataGrid1.TableStyles.Clear()

 With pDatagrid
  .MappingName = "TeamPlayers"
  .AlternatingBackColor = Color.LightGoldenrodYellow
  .GridLineColor = Color.Black
  .ForeColor = Color.Blue
 End With

 With Col1 '*
  .MappingName = "Players" '*
  .HeaderText = "Player" '*
  .Width = 260 '*
  .NullText = "No Data Avail" '*
  pDatagrid.GridColumnStyles.Add(Col1) '*
 End With '*
 DataGrid1.TableStyles.Add(pDatagrid)

End Sub


I hope this will help you


Proud To Be Pinoy
 
Old September 24th, 2004, 02:50 AM
Authorized User
 
Join Date: Jun 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to SupaHoopsa Send a message via AIM to SupaHoopsa Send a message via Yahoo to SupaHoopsa
Default

I managed to fix this thanks to some advice I received from another forum. I needed to reset the datagrid's datasource after applying the tablestyle.

Thanks for taking the time to help, it's greatly appreciated.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding content control to table's row rezarezash Word VBA 0 August 23rd, 2008 12:36 AM
Adding XSLT transformed XML content dynamically jacob ASP.NET 1.x and 2.0 Application Design 2 December 1st, 2005 04:40 PM
Tablestyle not working for datagrid travm222 VB.NET 3 November 30th, 2005 05:43 PM
Datagrid cell content value sinba Beginning VB 6 1 August 24th, 2004 01:58 PM
adding content to an already loaded page adeptz Javascript 5 March 19th, 2004 06:53 AM





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