473,395 Members | 1,675 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,395 software developers and data experts.

resetting datagrid

VM
How can I reset a datagrid? In my code, on an event, I do all the databinding of the datagrid to the dataset dynamically:

.... //get the Dataset

DGOrders.SetDataBinding(DSMyTrans, "ClientTrans");
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "ClientTrans";
DataColProds.HeaderText = "Desc";
DataColProds.MappingName = "description";
ts1.GridColumnStyles.Add(DataColProds);
DGOrders.TableStyles.Add(ts1);
DataColProds.Width = 140;
myDataColItemNumber.HeaderText = "Item No.";
myDataColItemNumber.MappingName = "itemid";
ts1.GridColumnStyles.Add(myDataColItemNumber);
DGOrders.TableStyles.Add(ts1);
myDataColItemNumber.Width = 70;
....

What can I do so, when I click again, it erases/deletes all columns and data and regenerates it with the above code?
Thanks,
VM

Nov 15 '05 #1
3 9325
This will do:
this.dataGrid1.DataSource = null;

this.dataGrid1.Refresh();

"VM" <None> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
How can I reset a datagrid? In my code, on an event, I do all the databinding of the datagrid to the dataset dynamically:

... //get the Dataset

DGOrders.SetDataBinding(DSMyTrans, "ClientTrans");
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "ClientTrans";
DataColProds.HeaderText = "Desc";
DataColProds.MappingName = "description";
ts1.GridColumnStyles.Add(DataColProds);
DGOrders.TableStyles.Add(ts1);
DataColProds.Width = 140;
myDataColItemNumber.HeaderText = "Item No.";
myDataColItemNumber.MappingName = "itemid";
ts1.GridColumnStyles.Add(myDataColItemNumber);
DGOrders.TableStyles.Add(ts1);
myDataColItemNumber.Width = 70;
...

What can I do so, when I click again, it erases/deletes all columns and data and regenerates it with the above code?
Thanks,
VM

Nov 15 '05 #2
VM
This did help but I have another problem...

Although it resets my datagrid, I can't add the same column to the datagrid (error: "The data grid table styles collection already contains a table style with the same mapping name."):
....

DGOrders.DataSource = null;

DGOrders.Refresh();

DGOrders.SetDataBinding(DSMyTrans, "ClientTrans");

ts1.MappingName = "ClientTrans";

DataColProds.HeaderText = "Desc";

DataColProds.MappingName = "description";

ts1.GridColumnStyles.Add(DataColProds);

DGOrders.TableStyles.Add(ts1); //error comes up here

DataColProds.Width = 140;

How come?
Thanks,

VM

"codewriter" <co**************@yahoo.com> wrote in message news:%g******************@news20.bellglobal.com...
This will do:
this.dataGrid1.DataSource = null;

this.dataGrid1.Refresh();

"VM" <None> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
How can I reset a datagrid? In my code, on an event, I do all the databinding of the datagrid to the dataset dynamically:

... //get the Dataset

DGOrders.SetDataBinding(DSMyTrans, "ClientTrans");
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "ClientTrans";
DataColProds.HeaderText = "Desc";
DataColProds.MappingName = "description";
ts1.GridColumnStyles.Add(DataColProds);
DGOrders.TableStyles.Add(ts1);
DataColProds.Width = 140;
myDataColItemNumber.HeaderText = "Item No.";
myDataColItemNumber.MappingName = "itemid";
ts1.GridColumnStyles.Add(myDataColItemNumber);
DGOrders.TableStyles.Add(ts1);
myDataColItemNumber.Width = 70;
...

What can I do so, when I click again, it erases/deletes all columns and data and regenerates it with the above code?
Thanks,
VM

Nov 15 '05 #3
this usually works for me:

grid.SetDataBinding( null, "" );

----------------------------

"VM" <None> wrote in message news:#x**************@TK2MSFTNGP10.phx.gbl...
How can I reset a datagrid? In my code, on an event, I do all the
databinding of the datagrid to the dataset dynamically:

.... //get the Dataset

DGOrders.SetDataBinding(DSMyTrans, "ClientTrans");
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "ClientTrans";
DataColProds.HeaderText = "Desc";
DataColProds.MappingName = "description";
ts1.GridColumnStyles.Add(DataColProds);
DGOrders.TableStyles.Add(ts1);
DataColProds.Width = 140;
myDataColItemNumber.HeaderText = "Item No.";
myDataColItemNumber.MappingName = "itemid";
ts1.GridColumnStyles.Add(myDataColItemNumber);
DGOrders.TableStyles.Add(ts1);
myDataColItemNumber.Width = 70;
....

What can I do so, when I click again, it erases/deletes all columns and data
and regenerates it with the above code?
Thanks,
VM
Nov 15 '05 #4

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

Similar topics

3
by: The Plankmeister | last post by:
Hi... I'm getting to grips with custom error handling, and am wondering if it is possible to somehow reset all the content already sent to the browser, and send some new stuff in its place. ...
4
by: Job Lot | last post by:
On form load my datagrid gets populated with values from database table. How can I reset values in my DataGrid to 0 on click of a button? thanks
8
by: riprod | last post by:
Someone in the IIS newsgroup suggest I post this here, so sorry in advance for the cross posting. I have a Win 2003 SP1 with IIS 6 and host about 40 websites, most of them useing ASP/VB with...
1
by: Frantic3d | last post by:
I just started using Access' Template file "Time & Billing Database" Well among other items I need to change the biggest right now is resetting the Client, Employee, Project ID #'s to start at 1. ...
2
by: DeveloperPDX | last post by:
I am creating a page and I need to add a reset button (like you would with HTML forms). Is there any way to do this other than resetting individual controls? Basically I need to page to return to...
1
by: Matthew Wieder | last post by:
Hi - I wanted to capture the enter button on a form since I have a datagrid with the first column being a delete button and if someone hits enter it deletes the first record. I coded: private...
3
by: No One | last post by:
This seems to be related to the ViewState error that is now starting to plague ASP.Net apps. When the Application Pool is recycled, the Session seems to be getting reset. When this is done,...
1
by: Sam | last post by:
Hi, I'm trying to clear my datagrid. For this I was thinking about reseting my its datasource (dataset) to nothing and then refreshing the datagrid using refresh. Is that the correct method, if so...
4
by: Ian Davies | last post by:
Hello I am struggling for a solution to clear some fields on my webpage that takes their values from some sessions My solution below works when the button is clicked twice. I sort of know why I...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.