Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How do you sort the data in datagrid?

Answers were Sorted based on User's Feedback



How do you sort the data in datagrid?..

Answer / murty

By setting "allow sorting" property of the datagrid to
true we can sort the records in the data grid

Is This Answer Correct ?    3 Yes 1 No

How do you sort the data in datagrid?..

Answer / shiva

Protected Sub Sorting(ByVal sender As Object, ByVal e As
GridViewSortEventArgs)
Dim DESCENDING As String = "DESC"
Dim ASCENDING As String = "ASC"

Dim sortExpression As String = e.SortExpression
If GridViewSortDirection = SortDirection.Ascending
Then
GridViewSortDirection = SortDirection.Descending
SortGridView(sortExpression, DESCENDING)
Else
GridViewSortDirection = SortDirection.Ascending
SortGridView(sortExpression, ASCENDING)
End If
End Sub
(Call this onsorting in datagrdi)
2)
Public Property GridViewSortDirection() As SortDirection
Get
If ViewState("sortDirection") Is Nothing Then
ViewState("sortDirection") =
SortDirection.Ascending
End If
Return CType(ViewState("sortDirection"),
SortDirection)
End Get
Set(ByVal value As SortDirection)
ViewState("sortDirection") = value
End Set
End Property
3) Private Sub SortGridView(ByVal sortExpression As String,
ByVal direction As String)
Try
Dim dt As DataTable = BindData().Tables(0)
Dim dv As New DataView(dt)
dv.Sort = sortExpression + " " + direction
gdvCamp.DataSource = dv
gdvCamp.PageIndex = 0
gdvCamp.DataBind()

Catch ex As Exception
Response.Write(ex.Message)
End Try

End Sub 'SortGridView

Bing the data like fallows
Private Function BindData() As DataSet
Binding Goes here which should returns dataset to above
function
End FUnction

Is This Answer Correct ?    1 Yes 0 No

How do you sort the data in datagrid?..

Answer / vamseedhar

datagrid has a property for sorting and paging

Is This Answer Correct ?    0 Yes 1 No

How do you sort the data in datagrid?..

Answer / sunil

In a simple method,

DataSet ds = new DataSet();
// you must populate the dataset
DataTable dt = ds.tables[0];
DataView dv = new DataView(dt);
dv.Sort = dt.Columns[0];
// This will sort first column in ascending
dv.Sort = dt.Columns[0] + " DESC";
// This will sort first column in descending

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More ADO.NET Interview Questions

Which is the best institute in navi mumbai to learn DotNet

2 Answers  


Features and disadvantages of dataset?

2 Answers   CarrizalSoft Technologies, Infosys, Microsoft, Sampath Software,


Give an example of a .net application which connects to microsoft access database using ado.net classes.

0 Answers  


What is a sqldataadapter?

0 Answers  


How you will set the datarelation between two columns?

3 Answers  


What are the steps to connect to a database?

0 Answers  


What is dataset object? Explain the various objects in dataset.

0 Answers  


What does executequery return?

0 Answers  


What does adodb stand for?

0 Answers  


When we are running the Application, if any errors occur in the Stored Procedure then how will the server identify the errors?

5 Answers   HCL,


OleDbDataAdapter ole=new OleDbDataAdapter(new OleDbCommand ("select * from login",oleDbConnection1)); OleDbCommandBuilder cmd=new OleDbCommandBuilder(ole); ole.Fill(dataSet11,"login"); DataRow drow=dataSet11.Tables ["login"].NewRow(); drow[0]=textBox1.Text; drow[1]=textBox2.Text; drow[2]=textBox3.Text; dataSet11.Tables["login"].Rows.Add (drow); ole.UpdateCommand=cmd.GetUpdateCommand(); ole.Update(dataSet11,"login"); MessageBox.Show("one row added"); this gives exception.how to solve it

1 Answers   Nimaya,


What are the Different layers in ADO.Net?

7 Answers  


Categories