In a window application I m feeling a data table at the time of page load and i have some buttons like Save and Display on the page.
When i save a new record it saved successfully but at the time of display it does't show the new added record because i feel the data table at page load which have no new added record.
The one way to display the new record is that i should fill data table again at Display button click. But it effects speed constraints.
Have any another suitable idea to display new added record.
Thanks in advance!
It depends upon the code you have written in button's handler. If the DataTable instance is already has been bind with the UI then you should have to add a row into that DataTable instance while saving it to the database.
Related
I am working on C# Windows app that reads data from SQL database and shows it in datagridview. I have printDocument1 imported to my form and print button that prints data from datagridview. I made it using a code from this page:
https://www.codeproject.com/Articles/28046/Printing-of-DataGridView
It works like a charm but I need one more option:
currently when form loads it fills up datagridview with data of a certain record. Pressing print button will print datagridview with current record.
Pressing next button will fill up datagridview with data of next record.... it's all working.
I just need somehow (after pressing PRINT ALL button) to print all the records from my database all together. I just can't figure out where to call a code which will refresh DGV with new data and loop through printing process...
Basically I want to print all the records from my DB and present it just like it is in DGV. I'm also using headers with current day in my printing so it needs to be in order with datas from DGV.
any idea please?
Use ObservableCollection for storing your data from db. It will track changes on the collection and will automatically refresh the view to which it is bound.
about the collection: What is the use of ObservableCollection in .net?
How to use with your datagridview: Binding ObservableCollection to DataGridView
How to get all record data from master data to another grid without change anything from master data and save it into new grid like this picture
into this grid
In the header, I have routingID and I want to get my operationMaster into my new grid in picture 2, any suggestion... I try with PXSelectJoin but it just gets data in master routing, and if I delete the line in picture 2 in my master will be deleted too. i want to get data just in screen to save it in into picture 2
Any Suggestion...
create a db table that will contain data from grid2, corrsponding DAC (dac2) and graph (graph2).
Then you can use an graph2 action to import data from grid1 to grid2. In the action you read data from grid1 using PXSelect ..., and insert it into corresponfing data view of graph2 which contains DAC2 records.
I've one grid view which shows the current orders to supplier with the latest order at the top. Whenever customer places any order for that supplier, that order should be shown in the supplier grid view. For that I am refreshing the supplier order page every one minute so that the grid view get updated and will show the new orders if any.
But it will be rare that at every one minute a new order will be placed, so it makes no sense for me to refresh whole page every one minute. The only reason that I've given refresh interval of 1min is that it is necessary to display the orders to the suppliers as soon as they placed by customers.
What I want to do is that whenever a new row is inserted in my order table in db for particular supplier, I want to add the new row at the top to the grid view at client side with some animatio**n like masking that row with some colored overlay which fade out in some time. And this should be done **without refreshing the whole page.
I am not able to figure out how should I add new row to grid view whenever new row added to db without refreshing whole page.
You may try Nodejs and Socket to send/broadcast the message to clients every times successfully updated the table
You can probably use the update-method you are using for your page today, but then use a javascript solution to update only part of the page.
Take a look a these questions and answers for example, the should point you in the right direction even if they may not be a perfect fit for your problem:
Rebind gridview using AJAX (without post back)
update datagridview using ajax in my asp.net without refreshing the page.(Display real time data)
I have a DataGridView that displays data from an SQL table. It is using sqldependency so that an alert is made when the data changes, and the DataGridView immediately displays the updated data. New rows will be added to this table regularly, and when this happens I want to take only those new rows from the first data grid and populate a separate DataGridView.
I've experimented a bit with RowAdded event, but it hasn't been entirely straightforward because it creates an alert for every row in the table whenever the grid view is updated by sqldependency.
Does anyone have experience doing something similar?
Let's call the first DataGridView with all the rows Grid A and the DataGridView that shows only new rows Grid B. Don't define the contents of Grid B by observing changes to Grid A. Instead, create your own definition of what a "new row" is. One easy way to do this is to make a copy of the contents of Grid A during every update (in the OnChange event of our SqlDependency object). Then, on the next update you'll be able to select rows into the "new rows" DataSet.
Here's the pseudo-code for the OnChange handler for your SqlDependency object (this should be watching the SqlCommand that fills Grid A):
Run a SqlCommand that selects rows from the Grid A datasource with an NOT IN clause that excludes rows with ID in a 2nd table called LastUpdate (see step 2). This will be the data source for Grid B
Run a SqlCommand that copies all rows of the Grid A data source to the LastUpdate table. It may be easiest to just delete the contents of LastUpdate first, then run a statement of the form: INSERT INTO LastUpdate(ID) SELECT ID FROM table_x
Update the Grid A normally
The point I want to emphasize is that this update strategy creates an effective separation between data queries and the UI. In other words, the data that drives Grid B does not in any way depend on Grid A. If you stick with this principle, you should wind up with a much more maintainable application.
I'm trying to create an ASP.NET/C# page that allows the user to edit a table of data, add rows to it, and save the data back to the database. For the table of data, I'm using a DataGrid whose cells contain TextBoxes or CheckBoxes. I have a button for adding rows (which works) and a button for saving the data. However, I'm quite stuck on two things:
The TextBoxes and CheckBoxes should retain their values on postback. So if the user edits a TextBox and clicks the button to add more rows, the edits should be retained when the page reloads. However, the edits should not be saved to the database at this point.
When the user clicks the save button, or anytime before, the DataTable underlying the DataGrid needs to be updated with the values of the TextBoxes and CheckBoxes so that the DataTable can be sent to the database. I have a method that does this, but I can't figure out when to call it.
Any help getting this to work, or suggestions of alternative user interfaces that would behave similarly, would be appreciated.
Take a look at the ASP.NET GridView control. It's newer than the DataGrid and has editing features, editing events, etc built in.
Check out the following website:
http://highoncoding.com/Categories/7_GridView_Control.aspx
There are tons of articles on the above link about the GridView control.