| |
GeekInterview.com > Interview Questions > Microsoft > DataGrid
| Print | |
Question: Hi, How to sort the data in Datagrid ? when we use DataBound event of Datagrid, I want to display te data using controls.... For an example, If i click a button, which is outside of the datagrid, entire data should be shown. 1st column in TextBoxs. second column in Drop down List Boxs.. How to bind the data in Dropdownlist,which is in DataGrid at run time? Row1 Row2 Row3 Row4 ----------------- This is the record in datagrid... When we click button (Bottom of the DataGrid), This Record should be shown... Row1 in TextBox,,, Row2 in TextBox, Row3 in DropDownlistbox, Row4 in TextBox... How to do this one? Which event we should use?... Please let me know the code for this ... Thanks in Advance... Ravi Majji
|
| October 10, 2006 23:39:00 |
#2 |
| PavanKumar |
Member Since: Visitor Total Comments: N/A |
RE: Hi, How to sort the data in Datagrid ? ... |
| Hi,In order to sort the data in the datagrid apply rowFilters. . . This can be done by using either a DataView or a DataTable. The data that we get from the database is stored in the tables and dataview which allow us to work with the data instead of making trips to the server. For instance SqlCommand cmd=new SqlCommand();SqlDataAdapter da=new SqlDataAdapter();DataView dView;DataSet ds = new DataSet();cmd.Connection=con;cmd.commandText = "Select * from emp";da.selectCommand = cmd;da.fill(ds,"emp");dView = ds.Tables["emp"].DefaultView;dView.Sort = " Age asc";By applying the sort filter as stated above you can sort your values.. . . . . .Thanks & Regards PavanKumar Sriramula |
| |
Back To Question | |