Using Radgridview directly for data Manipulation - c#

So i am using RadGridView for Winforms.
Now what i want to do is to perform data manipulation in the radgridview and datasource to get updated after the row loses foucs. I don't want to use textboxes or any other control for entering data.
Something like this
And after i press the new add new row and enter data
Now this data isn't being updated in the dataSource to update i need a query that needs to executed against the datasource.
Now i haven't been able to build a query because i haven't been able to figure out how to access the data of the newly created cells so that i can build a query and pass to SQLCeDataAdapter for execution.
Any pointers will be appreciated.

Im not sure about RadGridView, but I use DataGridView, wich I guess works the same way
You need to get the datarow so u can update to the database
DataRow row = ((DataRowView)eTipoDocumentoBindingSource.Current).Row;
once you have it, you can use the DataTableAdapter method update(row) to save changes to the database
You can do that, either in the click event of a save button, or in the event of focused row changed

Related

How can I access SqlDataSource already selected data, if it is bind to a GridView?

I have a GridView and a SqlDataSource. All binding done in aspx, works correctly and Select calls an SP with parameters.
Now I would like to access the bound data programmatically, in stuctured form, not parsing back it from the UI, using cells or .FindControl or other hacks. I also do not want to reselect the data using my SqlDataSource's Select.
I've debugged the code but can not find any structured data neither in my GridView variable neither in my SqlDataSource variable. Maybe I was browsing the wrong properties or a cast was missing.
Thx in advance
I don't think you can do that. When you bind the data from an SQL DataSource to a Gridview, it fetches the data to display and then that's it. It's gone.
When a GridView updates the data, it uses the key field ID and the text in the GridView to do it. There is no other DataTable or other structure behind the scenes.

C# : Resetting DataGridView for new DataTable

Ok so I'm trying to make a simple SQL CE Viewer application just to view my local databases for another application, I have it setup so that I can select what database I want to open and then it automatically populates a combo box with all of the tables in the database. When I select a table it populates a DataGridView with the records in the table.
My problem is switching between tables. I can't seem to get the DataGridView to remove everything from the previous table and re-populate the DataGridView with the new table information. Of course each table has different columns and rows and such.
I've googled and searched on here and every suggestion I find doesn't seem to work. It populates the DataGridView with the first table just fine, but when I select another it basically adds the columns and rows into whatever was there....
How can I get the DataGridView to completely clear for new data?
And please don't tell me to use dataGridView1.DataSource = null; tried that, doesn't work.
Well, I checked it in one of my programs and just changing DataSource property is working fine. I didn't have to use datagridview.Refresh(). Maybe it depends on the kind of DataSource, which you are using to set datagridview data?
Write this line after you have done populating the DataSource with the new data
dataGridView1.Refresh();
You don't need to clear the DataGridView directly. Its always handled by modifying the DataSource of the DataGridView.
If there is nothing else in the form, you can simply call InitializeComponent() again. But I think #Josh is right.

How to clear data in DataGridView?

I am new to C#. How to Clear data in DataGridView?
I have some data in datagridview and I have one drop down box at every index changed
I want datagrid view will be changed. but I did not get the solution just i Added to
previous data can any one help
if you use data source to fill the grid use:
dataGridView1.DataSource=null;
dataGridView1.DataBind();
if you fill the grid programmatically use:
dataGridView1.Rows.Clear();
If you want the DataGridView change when the Dropdownlist change so u just reuse the Code grant value to Datagridview.

How can I add one row to a DataGridView?

I work with a WinForms app.
I want to add one row to a DataGridView that this row must enter to database.
What event handler must I use to do this?
Is your DataGridView bound to that database? If so, you should be adding and deleting rows in that data source, not in the grid control itself. Try calling the AddNew method on the binding source.
If you're using a standalone DataGridView that isn't bound to a database, then you can call one of the many overloads of the Add method of the grid control's Rows collection.
This might help you out to add a row to the DataGridView:
http://msdn.microsoft.com/de-de/library/system.windows.forms.datagridview%28v=vs.80%29.aspx
If the DataGridView isn't bound to the database, try to bound it or write the data to the database programmatically.

update data grid view automatically

I have two windows forms. The first form shows list of records from sql. When you click some cell of a record in DataGridView it shows the second form. In the second form you can edit and update the record. I want DataGridView to be
updated automatically when user close second form. What should I do?
Are you using data bindings, or do you manually fill the grid ? With data bindings its very easy... if the data is contained in a DataTable and you change it somewhere, the change will be reflected automatically in the DataGridView. It also works with objects that implement INotifyPropertyChanged, and lists that implement IBindingList.
If you're not using bindings, you can :
locate the cell that contains the edited value, and update it manually, OR
refill the entire grid
Fill the grid with data from the database again?

Categories