473,386 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

HELP PLEASE: Cannot refresh Datagrid

Hey guys, please HELP

I am going nuts with the datagrid control.

I cannot get the damn control to refresh. I am using soap to get information
from a web service. I have an XML writer output the file to a folder, and
then I read it back into the dataset using the dataset1.readxml. Up to this
point, everything works wonderfully. The query executes, the dataset gets
populated, and I get the results displayed in the datagrid.

The problem:

When I run another query, everything goes as before expect that the datagrid
columns WON'T REFRESH. I can see the data changes, but the columns remain,
and since the columns don't match any other column in the new set,
everything is (null).

How do I REFRESH the grid columns?.... I mean, I have tried everything, I
have called the dataset.clear() method, I have called the
dataset.table.clear() method, I have unbound the grid from the datasource
and rebound again, deleted all tables, etc etc etc. I just can't get rid of
the damn columns.

Please help, it's been a long weekend and it is getting frustrating.....

Thank you in advance.

Regards.
Nov 20 '05 #1
7 15417
Cor
Juan,
Did you know that there is a special newsgroup
microstof.public.dotned.aspnet.datagridcontrol
I think that you get in that newsgroup the best answer.
Success
Cor
Nov 20 '05 #2
Hi Juan,

First of all, how do you bind the DataSet? I'd strongly suggest using
SetDataBindingMethod.
Second, do you create TableStyles/ColumnStyles manually? If yes, you might
need to re-create them after a new data source has been bound to the grid.

Probably you could also post a code snippet to illustrate the problem?

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Juan Romero" <ju******@optonline.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hey guys, please HELP

I am going nuts with the datagrid control.

I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output the file to a folder, and
then I read it back into the dataset using the dataset1.readxml. Up to this point, everything works wonderfully. The query executes, the dataset gets
populated, and I get the results displayed in the datagrid.

The problem:

When I run another query, everything goes as before expect that the datagrid columns WON'T REFRESH. I can see the data changes, but the columns remain,
and since the columns don't match any other column in the new set,
everything is (null).

How do I REFRESH the grid columns?.... I mean, I have tried everything, I
have called the dataset.clear() method, I have called the
dataset.table.clear() method, I have unbound the grid from the datasource
and rebound again, deleted all tables, etc etc etc. I just can't get rid of the damn columns.

Please help, it's been a long weekend and it is getting frustrating.....

Thank you in advance.

Regards.


Nov 20 '05 #3
I am not talking about ASP .NET.

I am talking about the datagrid control for VB .NET

Thanks for your answer anyways.

"Cor" <no*@non.com> wrote in message
news:3f**********************@reader21.wxs.nl...
Juan,
Did you know that there is a special newsgroup
microstof.public.dotned.aspnet.datagridcontrol
I think that you get in that newsgroup the best answer.
Success
Cor

Nov 20 '05 #4
Cor
I know Juan,
That group seems to be for special for the ASP.Net datagrid control

I did not say, go away :-)

But it is just an advise.
Cor
Nov 20 '05 #5

Have you called AcceptChanges() afterards ?

"Juan Romero" <ju******@optonline.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hey guys, please HELP

I am going nuts with the datagrid control.

I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output the file to a folder, and
then I read it back into the dataset using the dataset1.readxml. Up to this point, everything works wonderfully. The query executes, the dataset gets
populated, and I get the results displayed in the datagrid.

The problem:

When I run another query, everything goes as before expect that the datagrid columns WON'T REFRESH. I can see the data changes, but the columns remain,
and since the columns don't match any other column in the new set,
everything is (null).

How do I REFRESH the grid columns?.... I mean, I have tried everything, I
have called the dataset.clear() method, I have called the
dataset.table.clear() method, I have unbound the grid from the datasource
and rebound again, deleted all tables, etc etc etc. I just can't get rid of the damn columns.

Please help, it's been a long weekend and it is getting frustrating.....

Thank you in advance.

Regards.

Nov 20 '05 #6
-- i tried this and it works 4 me. I'm not sue if this is what you were
trying to acheive ?

Public Class Form1

Inherits System.Windows.Forms.Form

Dim ds As New DataSet("MySet")

Dim myTab As DataTable

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Friend WithEvents dg As System.Windows.Forms.DataGrid

Friend WithEvents ClearTab As System.Windows.Forms.Button

Friend WithEvents SaveXML As System.Windows.Forms.Button

Friend WithEvents ReadXML As System.Windows.Forms.Button

Friend WithEvents AddName As System.Windows.Forms.Button

Friend WithEvents aName As System.Windows.Forms.TextBox

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Me.dg = New System.Windows.Forms.DataGrid

Me.ClearTab = New System.Windows.Forms.Button

Me.SaveXML = New System.Windows.Forms.Button

Me.ReadXML = New System.Windows.Forms.Button

Me.AddName = New System.Windows.Forms.Button

Me.aName = New System.Windows.Forms.TextBox

CType(Me.dg, System.ComponentModel.ISupportInitialize).BeginIni t()

Me.SuspendLayout()

'

'dg

'

Me.dg.DataMember = ""

Me.dg.HeaderForeColor = System.Drawing.SystemColors.ControlText

Me.dg.Location = New System.Drawing.Point(144, 128)

Me.dg.Name = "dg"

Me.dg.Size = New System.Drawing.Size(208, 128)

Me.dg.TabIndex = 0

'

'ClearTab

'

Me.ClearTab.Location = New System.Drawing.Point(24, 48)

Me.ClearTab.Name = "ClearTab"

Me.ClearTab.TabIndex = 1

Me.ClearTab.Text = "Clear"

'

'SaveXML

'

Me.SaveXML.Location = New System.Drawing.Point(184, 48)

Me.SaveXML.Name = "SaveXML"

Me.SaveXML.TabIndex = 2

Me.SaveXML.Text = "SaveXML"

'

'ReadXML

'

Me.ReadXML.Location = New System.Drawing.Point(344, 48)

Me.ReadXML.Name = "ReadXML"

Me.ReadXML.TabIndex = 3

Me.ReadXML.Text = "Read XML"

'

'AddName

'

Me.AddName.Location = New System.Drawing.Point(24, 96)

Me.AddName.Name = "AddName"

Me.AddName.TabIndex = 4

Me.AddName.Text = "Add Name"

'

'aName

'

Me.aName.Location = New System.Drawing.Point(112, 96)

Me.aName.Name = "aName"

Me.aName.TabIndex = 5

Me.aName.Text = ""

'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(480, 273)

Me.Controls.Add(Me.aName)

Me.Controls.Add(Me.AddName)

Me.Controls.Add(Me.ReadXML)

Me.Controls.Add(Me.SaveXML)

Me.Controls.Add(Me.ClearTab)

Me.Controls.Add(Me.dg)

Me.Name = "Form1"

Me.Text = "Form1"

CType(Me.dg, System.ComponentModel.ISupportInitialize).EndInit( )

Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim dr As DataRow

ds.Tables.Add("myTable")

myTab = ds.Tables("myTable")

myTab.Columns.Add("FirstName")

dr = myTab.NewRow

dr("FirstName") = "John"

myTab.Rows.Add(dr)

dg.DataSource = ds.Tables("myTable")

End Sub

Private Sub SaveXML_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles SaveXML.Click

ds.WriteXml("C:\myxml.txt")

End Sub

Private Sub ReadXML_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ReadXML.Click

ds.Clear()

ds.ReadXml("c:\myxml.txt")

End Sub

Private Sub AddName_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles AddName.Click

Dim dr As DataRow

dr = myTab.NewRow

dr("FirstName") = aName.Text

myTab.Rows.Add(dr)

End Sub

Private Sub ClearTab_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ClearTab.Click

ds.Clear()

End Sub

End Class

"Juan Romero" <ju******@optonline.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hey guys, please HELP

I am going nuts with the datagrid control.

I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output the file to a folder, and
then I read it back into the dataset using the dataset1.readxml. Up to this point, everything works wonderfully. The query executes, the dataset gets
populated, and I get the results displayed in the datagrid.

The problem:

When I run another query, everything goes as before expect that the datagrid columns WON'T REFRESH. I can see the data changes, but the columns remain,
and since the columns don't match any other column in the new set,
everything is (null).

How do I REFRESH the grid columns?.... I mean, I have tried everything, I
have called the dataset.clear() method, I have called the
dataset.table.clear() method, I have unbound the grid from the datasource
and rebound again, deleted all tables, etc etc etc. I just can't get rid of the damn columns.

Please help, it's been a long weekend and it is getting frustrating.....

Thank you in advance.

Regards.

Nov 20 '05 #7
Guys, I just cannot get this %^^$&% datagrid to refresh. I managed to
overcome the columns problem, and here is where I am now:

As you will see in the below piece of code, Once I get the datatable, I EVEN
check to see if it exists on the dataset. If it finds it, IT DELETES all the
rows from the table (another attempt to make it work) and then it drops the
table. After dropping it adds the table again to the dataset.

The intersting part:
Deleting all the records from the table actually makes the grid refresh, so
it looks empty, but when I reload the table, IT DOES NOT DISPLAY THE
RECORDS, it now stays EMPTY.

Sigh.... I have included every possible instruction I KNOW OF to make the
damn grid refresh, yet, it shows nothing...

Please help.

Here is a piece of code:

Dim x As DataTable = GetDataTable(Results)

x.TableName = tvDesc.SelectedNode.Text

If Not DataSetSF.Tables(x.TableName) Is Nothing Then

DataSetSF.Tables(x.TableName).Clear()

DataSetSF.Tables.Remove(x.TableName)

DataSetSF.AcceptChanges()

End If

DataSetSF.Tables.Add(x)

DataSetSF.Tables(x.TableName).AcceptChanges()

DataSetSF.AcceptChanges()

dgresults.SetDataBinding(DataSetSF, tvDesc.SelectedNode.Text)

dgresults.DataMember = tvDesc.SelectedNode.Text

dgresults.CaptionText = x.TableName & " - " &
DataSetSF.Tables(x.TableName).Rows.Count.ToString & " Records."

dgresults.Refresh()

dgresults.Update()
"Juan Romero" <ju******@optonline.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hey guys, please HELP

I am going nuts with the datagrid control.

I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output the file to a folder, and
then I read it back into the dataset using the dataset1.readxml. Up to this point, everything works wonderfully. The query executes, the dataset gets
populated, and I get the results displayed in the datagrid.

The problem:

When I run another query, everything goes as before expect that the datagrid columns WON'T REFRESH. I can see the data changes, but the columns remain,
and since the columns don't match any other column in the new set,
everything is (null).

How do I REFRESH the grid columns?.... I mean, I have tried everything, I
have called the dataset.clear() method, I have called the
dataset.table.clear() method, I have unbound the grid from the datasource
and rebound again, deleted all tables, etc etc etc. I just can't get rid of the damn columns.

Please help, it's been a long weekend and it is getting frustrating.....

Thank you in advance.

Regards.

Nov 20 '05 #8

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

Similar topics

8
by: EMW | last post by:
Hi, Could you please take a look and tell me what this means? Cor has tried to help me, but we haven't found it yet. Everytime I run this code, I get an exception error. Here is my code: ...
0
by: serge calderara | last post by:
Dear all, I am collecting data from an external source every 5 seconds. Then I map those incoming data to a dataset object attach to a datagrid. My datagrid content should map the dataset...
0
by: msnews | last post by:
Hi -- I'm very, very new to ASP.Net, and I've been trying for several days to figure out how to update a datagrid AND refresh it on the client side so that the page doesn't refresh. I've torn my...
0
by: Marcus | last post by:
Hello! I'm buildning a webpage in ASP.NET using Visual Basic. The page contains a datagrid, a dropdownlist, some textboxes and a couple of buttons. The datagrid displays barcodes from a table...
2
by: Dan | last post by:
Hi, I have a Datagrid in a simple form that I programmatically modify using something like that : Me.DataGrid1(RowID, ColID) = "blablabla" But my cell wont refresh unless I click on another...
12
by: chreo | last post by:
I GIVE UP...I can't refresh datagrid (dataset) I have datagrid = dgrPaczki Datasource of that datagrid = DataSetPaczki1.PACZKI_PAKOWALNIA (forgive me Polish words) Dataadapter which fills my...
0
by: mandrax7 | last post by:
I used Visual Studio 6 and I had made a simple program to access a SQL 2000 database, now I'm trying to do the same thing with Visual studio 20005, but.....nothing works. I used to connect with...
1
by: zombie212 | last post by:
I have devoloped a page in asp.net with datagrid with code behind in VB, to show the result of SP_ who2 ( SQL Server System stored proc). Now I have also added a refresh button to update the page,...
6
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi - I'm having trouble refreshing a datagrid control bound to a dataset that was created from the New Data Source wizard. What is the code required to refresh the datagrid with data from the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.