asp c#
i have a page where user selects an item and its quantity to purchase and next item and so on
all items selected are filled in datatable and shown in gridview
at the end of selecting items
when user clicks process button
i want to insert all items and its quantities in database
on pageload a datatable is empty
on btn_Select_Click i hv filled in few rows
on btn_Process_Click i want to loop through these rows and insert records in db for each row
but it returns zero rows
Your question is a little vague. "but it returns zero rows"... I'm guessing that what you mean is, that in the click handler for your button, when you access your grid object, it has no rows in it?
Remember that each load of the page creates a whole set of brand new webcontrols. Webcontrol objects are not persisted in memory to be reused on each hit to the page.
If you want the same rows available on this new page that is being rendered after the button click, you have to re-bind your grid. I'm guessing that isn't happening in your code.
Related
The objective i'm trying to achieve is to display filtered data in the same gridcontrol.
So what I do is e.g A-DROPDOWN clicked, display XDATA in GRIDVIEW1. Then FilterA selected, this filter calls the "ADROPDOWN" clicked event again and then checks the appropriate filter then passes the appropriate sql query, then displays "YDATA" in GRIDVIEW1.
Now when I select B-DROPDOWN, ZDATA is displayed however below it is the YDATA. If I select C-DROPDOWN, VDATA is displayed howver below it is still the YDATA.
If I selected A-DROPDOWN then XDATA would be displayed then if I would selected B-DROPDOWN without selecting any of the filters, WDATA would be displayed cleanly in GRIDVIEW1 without any data below or above it. Would appreciate if anyone has any suggestions. Cannot show my code because its 20000 lines.
Would like to add. The alphabets assigned to the dropdowns and data represents the different datasets.
SOLVED !!!
Incase it is of help to someone. my update panel in my front end was only updating the gridview, not the table where the grid view was located . I simple made it so that my entire table where the gridview was located was updating. Many thanks.
is there any chance to make the navigating buttons operate on the whole database while the datagrid would show only the filtered results? I mean, I have a datagridview and some textboxes corresponding to the columns. When I filter my data, the datagridview gets filled and the textboxes showing the data of the first row. When i move through the datagridview to the next row, the values in the textboxes change correspondingly. Now, I would like to filter first, then to click on a datagrid row. Afterwards,( because i don't need the filtered results any more) i would like just to drop them and to navigate just through common buttons on the whole unfiltered data. For example:
Filter for all Names starting with "S",
DoubleClick on the Row,
Navigate from this entry with the buttons, not
only on the names starting with "S", but to the next or previous
entry in the database.
I know how to navigate using BindingSource.MovePrevious() or MoveNext(), but as long as I use the same bindingSource i navigate through the same filtered set of data.
Any suggestions would be very much appreciated!
I am keeping DataTable in session variable.
A GridView having template column checkbox with autopostback set to true.
oncheckchange event of checkbox is tracked to delete or add rows in session DataTable.
Application opens multiple instances of same page and respective GridView on page is source for adding or deleting rows in (one for all) session DataTable.
Now problem is that I cannot click fast on checboxes in a gridview.
Apparently it look like server side process of updating session table is very
slow. Sometimes cached clicks come into action quite slowly. Please guide how to maintain session DataTable efficiently?
Note:
I have checkbox in the header row of every GridView as well, which checks and un-checks every row present in Gridview.
Not sure if I have the correct subject line. Here is my issue. I have a form with 2 GridView. One GridView has a list of all zipCodes. The users is to select a location from a dropdown list, then select the zipcodes he/she wants to be assigned to that location and then click the "Add" button. The zipcodes then appear in the second GridView. When the user clicks the "Save" button, the data is sent to the database. The is also a "Remove" to remove zipcode(s) in the second GridView.
How do I track changes only in the second GridView. There could be 1000's of zipcode in the second GridView. Do I just remove and re-insert the list for that location evertime the user click save? I was thinking of using a DataSet, add DataRows and then update, however I am not using a DataAdapter to load my dataset, so there is no way for me to use DataAdapter.Update(ds). I am using the SQLHelper.ExecuteDataset(parms)
Any ideas?
Anyone?
Forget Dataset. Dataset is a nightmare. Instead use a BindingList.
How can I Display selected row of Gridview data to next page in another Gridview?
For example,
In listing page I want to select particular row and take that data to another page and display over there.
I have two grid view one in 1st page
and next one in 2nd page. Now when I
select a record in 1st page gridview,
than that record will display on 2nd
page gridview on submit button click
from 1st page.
Pass the key of the record via the querystring... and then in rowdatabound event, select the row when the data bound record matches the key in the QS.
For more protection, you can use session to store the variable.
Why not have 2 gridviews, one above the other? The top gridview could be made to only show 1 record which is set to the id of the 2nd gridviews selected item identifier in code. Then in 2nd gridview, have an empty selected item template so that the selected item only shows once for both gridviews. That way the 2nd gridview is free to page through the entire set whilst the first retains the selected item for display above?