paging in gridview - c#

I had gridview which retriev data from database and filter this gridview when I select ddl .and I allow paging in this gridview .But I noticed that when i selected ddl and the gridview get it,s data and I do through pages number in paging and if I stoped in ex.page number 4.And when I selected ddl again the gridview get it,s data but it stop in page number 4.so how can I make gridview return to first page if i selected ddl.

In your event handler for the dropdownlist SelectedIndexChanged, add this:
GridView1.PageIndex = 0;

Related

when i give datasource to gridview, the combo in grid is auto selecting

after giving the datasource to grid the first cell of gridview combo is auto selection occuring in datagridview, how to prevent this?
Since it is a dropdown list you have to populate it separately and insert "Select" as 0th item.
I assume this is asp.net application. Here is the link how you can populate and bind dropdown in gridview.
how to bind a dropdownlist in gridview?

How get a new datatable after reordering the gridview

I populate a gridview from the db.
then i re arranged the rows in the gridview with javascript code.
i want to copy the rearranged gridview to a datatable
how it possible??
If you re-arranged your data using Javascript, you will have to update the database using Javascript. You will not be able to do if using server-side code.
Getting data and binding a GridView on the server-side and then rearranging it with Javascript is not a good idea. I suggest you either get your data purely from Javascript, or arrange your data on the server side before binding your GridView.
There could be multiple methods
First method
GridView row would have a hidden field in each row which should be updated with new row index and have a column for row index / order in database.
When user changes the row index of GridView Row, you will have to change the hidden fields of all effected with new rowindex. On server side you will have to iterate through the GridView rows and save the respective rows index / order in row column for order of row.
Second Method
You can send the changed rows index on each arrangement using the ajax (jquery ajax) and save the changed index in database row order column.
if you need to sort the gridview without reloading the page , then use an update panel enable and code for gridview pageindexchanging and sorting event , if you need any indication while processing use an updateprogress control .
If you are intended to update the data . then use ajax to send the data to a webmethod and update it into DB

How to load Gridview on dropdown selected index changed event?

I have a gridview contains only a drop down box and text box controls for inputting data.I can load the dropdown on gridview rowdatabound event and take the input on gridview roweditevent.Here my question is how to load this gridview it self on another dropdown selected index changed event ,Because nothing is there to load data in to the grid in terms of gridview.datasource ,but inside gridview dropdown is loaded on gridview rowdatabound event.

Add rows to GridView without Postback

Is it possible to add rows with web controls to a GridView using jquery?
Yes , gridview is rendered as table so you can insert new row
$('#<%=yourGridView.ClientID%>').append('<tr><td></td><td></td></tr>');

Combobox and Gridview

If we select the dropdown list Item then I want to display the Item Particulars in the Gridview Please Help me
On the SelectedIndexChanged of the dropdown rebind your GridView off of the selected value
Add a dropdownlist control, a button control, a grid view and an sqldatasource.
Configure the datasource first in sqldatasource.
I would recommend write a storeprodure to fetch data into the gridview (sqldatasource).
Bound the parameter to "controls" and select the dropdownlist. Now your DDL is bound to the gridivew. In his table click on advance properties and change property convertemptystringto null = false. (there property is something similar).
If you want a button to update the grid view, do this. Add the default event control to the button, put no code in it.
If you want to change the grid view content based on select directly then choose autopost on selected changed in properties of the DDL.
If everything is fine, this should populate your grid view based on contents in DropDownlist

Categories

Resources