GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  DataGrid
Go To First  |  Previous Question  |  Next Question 
 DataGrid  |  Question 7 of 14    Print  
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

  
Total Answers and Comments: 2 Last Update: October 27, 2006     Asked by: aspnet 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
July 25, 2006 07:54:45   #1  
Makesh. R        

RE: Hi, How to sort the data in Datagrid ? ...
Hi Friends Sorting in DataGrid.Using the SortCommand Event in the datagrid u can sort the value in datagrid.For Example.Dim con as new oledb.oledbconnection( connectionstring )con.open()Dim sql as stringsql query Dim DataAdapter as new oledb.oledbdataadapter(sql con)dim ds as new datasetdataadapter.fill(ds)Private Sub DGMain_SortCommand(ByVal source As Object ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles DGMain.SortCommand Dim datasort As DataView datasort LocalLibrary.GetDataSet(sql).Tables(0).DefaultView datasort.Sort e.SortExpression DGMain.DataSource datasort DGMain.DataBind() End SubBind the data in Datagrid at runtime ?Use ItemDataBound Event in datagrid.Private Sub DGMain_ItemDataBound(ByVal sender As Object ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DGMain.ItemDataBound If e.Item.ItemIndex > -1 Then Dim lblClose As dropdownlist lblClose CType(e.Item.FindControl( lblClose ) dropdownlist) If Not lblClose Is Nothing Then lblclose.items.add( dropdownassignvalue )lblclose.items( dropdownindex ).value assigned value End If End If End Sub
 
Is this answer useful? Yes | No
October 26, 2006 23:39:00   #2  
PavanKumar        

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
 
Is this answer useful? Yes | No

 Related Questions

In DataGrid, is it possible to add rows one by one at runtime. That means after entering data in one row next row will be added.

In win-forms what is the Efficient way to create a combobox when the DG_CurrentCellChanged ()has occured?[The problem which i am facing text typed on other column is disapearing ,if a combobox is created ]
View Question | Asked by : suresh

Latest Answer : Hi,You can use template column to add controls like label, textbox etc.The same way you can add datetime control also. ...

Latest Answer : refresh datagrid by calling it in postback ...
Read Answers (10) | Asked by : Prajakta Deshpande

Hi, How to sort the data in gatagrid ? when we use DataBound event of Datagrid,,,, I want to display the 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?
Read Answers (1) | Asked by : Ravi Majji

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...
Read Answers (2) | Asked by : aspnet

Hi, I was asked this in an Interview I want to add buttons,images,etc to the footer of a datagrid at runtime. how would i achieve this?
Read Answers (4) | Asked by : Yatin

Latest Answer : 1. In datagrid you have to do lots of task for sorting, paging. In gridview sorting, paging is much easier and you can do with only 2-3 line of coding.2. DataGrid control doesn't take full advantage of data source components. GridView fully support data ...
Read Answers (1) | Asked by : tuhina

Latest Answer : Cancel CommandDelete CommandEdit CommandUpdate CommandItem Command ...

How to get the content of Datagrid into excel format?I want to use this feature in Windows Application and C#, Visual Studio .NET 2003 
Latest Answer : for windows application u use excel object to create excel file ...


 Sponsored Links

 
Related Articles

Breaking up XML into Relational Data

Breaking up XML into Relational Data While the preceding example shows how to construct an XML representation over relational data the example in this section illustrates how you can shred XML data back into relational data This reverse operation can be useful if your application works with relation
 

Querying Data with Oracle XQuery

Querying Data with Oracle XQuery Starting with Oracle Database 10g Release 2 you can take advantage of a full featured native XQuery engine integrated with the database With Oracle XQuery you can accomplish various tasks involved in developing PHP Oracle XML applications operating on any kind of dat
 

Retrieving XML Data

Retrieving XML DataTo retrieve XML data from an XMLType table you can use a SELECT SQL statement just as you would if you had to query a relational table For example to select the employee with the id set to 100 from the employees XMLType table discussed in the preceding section you might issue the
 

Using XMLType for Handling XML Data in the Database

Using XMLType for Handling XML Data in the Database Being an object type XMLType can not only be used to store XML data in the database but also to operate on that data via its built in methods Regardless of the storage model you choose XMLType provides a set of XML specific methods to operate on XM
 

Using Oracle Database for Storing, Modifying, and Retrieving XML Data

Using Oracle Database for Storing Modifying and Retrieving XML Data With Oracle XML DB you have various XML storage and XML processing options allowing you to achieve the required level of performance and scalability One of the most interesting things about Oracle XML DB is that it allows you to per
 

ODP.NET - Techniques to Improve Performance while Retrieving Data

ODP NET Techniques to Improve Performance while Retrieving Data Performance tuning is a great subject in Oracle Volumes of books would not be enough to cover every aspect of performance tuning in Oracle However in this section we will only discuss the fundamental performance techniques while working
 

ODP.NET - Working with Bind Variables together with OracleParameter

ODP NET Working with Bind Variables together with OracleParameter With the help of OracleParameter you can include bind variables within any SQL statement These bind variables are nothing but run time query parameters The values in the SQL statement are bound at run time when we use bind variables m
 

ODP.NET - Populating a Dataset with a Single Data Table

ODP NET Populating a Dataset with a Single Data Table A dataset is simply a group of data tables These data tables can be identified with their own unique names within a dataset You can also add relations between data tables available in a dataset mosgoogle The following code gives you the details o
 

ODP.NET - Retrieving Typed Data

ODP NET Retrieving Typed Data While retrieving values from OracleDataReader we can extract information available in individual columns of a particular row either by using column ordinal position values or column names mosgoogle Retrieving Typed Data Using Ordinals ODP NET provides data specific enum
 

ODP.NET - Retrieving Data Using OracleDataReader

ODP NET Retrieving Data Using OracleDataReader OracleDataReader is simply a read only and forward only result set It works only if the database connection is open and it makes sure that the connection is open while you are retrieving data As the data that it retrieves is read only it is a bit faster
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape