Hi, here I have created the datatable dt,and attached to datasource i.e ultraGrid1.datasource =dt so,i dont have any dadadapter or dataset,so how can i save the data in the ultragrid drag and droped rows on the button click event.
Hello,
Thank you for contacting Infragistics Support.
In order to save changes you have made to your UltraGrid you need to call its UpdateData method. This method will update any modified information in the grid, sending it to the data provider. More about UpdateData methos you may find by following the next link http://help.infragistics.com/Doc/WinForms/current/CLR4.0/?page=Infragistics4.Win.UltraWinGrid.v14.2~Infragistics.Win.UltraWinGrid.UltraGridBase~UpdateData.html. You can also set when the grid will update its data source by setting UpdateMode property of the grid. More about this property you may find by following the next link http://help.infragistics.com/Doc/WinForms/current/CLR4.0/?page=Infragistics4.Win.UltraWinGrid.v14.2~Infragistics.Win.UltraWinGrid.UltraGrid~UpdateMode.html
Please note the grid only deals with its local DataSource, and the DataSource only get updates by the grid when something changes. When dealing with the DataSource and the back end (the database), the grid doesn't really have any involvement there. If you need to save the changes you have made in DataTable you need to use some back end. Please find attached sample where I have implemented saving the changes from UltraGrid to DataTable. Additionally when you click “Save Data To XML” button DataTable will be saved in XML file.
Please let me know if this is what you are looking for or if I am missing something.
hi,i have tried like this
{DataTable dt = new DataTable(); dt.Columns.Add("CustomerName",typeof(string)); dt.Columns.Add("CustomerID", typeof(int));
ultragrid1.Datasource=dt; }
private void ultraButton1_Click(object sender, EventArgs e) {
this.ultraGrid1.UpdateData(); DataTable dt = (DataTable)this.ultraGrid1.DataSource; }
created the data table dt,and performed drag and drop operation ,now on click of button data should save in ultragrid.
plzz help me to get the problem resolve
Hi,
Please let me know if you need my further assistance on this matter.
Thank you for using Infragistics Components.
hi,I have tried with that code,but it does not workthere is no drag and drop between rows and data save back to xml file.and one more thing i could not get is private const string DataAsXML = "data.xml"; private const string DataSchemaAsXML = "dataSchema.xml";there should exist data.xml file and dataschema.xml file??
Thanks in advance
I think the user is asking how to save the data after a drag and drop operation which is between rows and results in a reordering of the rows.
example: Row 1 becomes row 3.
The example you provided is for saving data between cells.
From what I seen, row movement uses something like UltraGrid1.Rows.Move(aRow, dropIndex).
But when this is written as in myNewDataTable = Ctype(UltraGrid1.DataSource, datatable) you can see edits to cells but the row index has not change. Row 1 is at position 1 in the datatable and so on.
I think (like to be wrong) the solution is to iterate through the grid and convert each ultragridrow to a datarow and save it to a datatable. Then save that to what you want.
JL
Thank you for your feedback.
I have checked my solution and it seems to work just fine. Please follow these steps in order to check if it is work in your environment:
1. Download my sample solution I have posted in my post from 20th of November. Here is the link for this download http://ko.infragistics.com/community/cfs-file.ashx/__key/CommunityServer.Components.PostAttachments/00.00.46.18.21/CAS_2D00_147384_2D00_S7N5N2.zip
2. Extract the solution and open it in Visual Studio.
3. Build the solution.
4. In solution Bin\Debug folder you will find UltraGridSaveToChanges.exe file. Start this file, drag and drop some cells in the grid and then click Save Data To XML button.
5. Close the application and start it again. It will load the grid as it was before you closed it.
Please find attached a short clip showing the application behavior on my machine. Please let me know if application works in your environment in this way.
Regarding constants DataAsXML and DataSchemaAsXML these are names I have used to create or load in exist the XML files representing the data table.
These two files are created when you click Save Data To XML button. When you start the application for the first time it is check if such files exist. If so the application loads the data table form the files and if not it creates new data table. This is where this check is made:
if (File.Exists(DataAsXML))
{
DataTable dataTable = new DataTable();
dataTable.ReadXmlSchema(DataSchemaAsXML);
dataTable.ReadXml(DataAsXML);
ultraGrid.DataSource = dataTable;
}
else
ultraGrid.DataSource = this.CreateDataTable();
Please let me know if you have any further questions.