Dim strConnString AsString =
System.Configuration.ConfigurationManager.ConnectionStrings.Item("ConnectionString").ToString()
Dim con AsNew SqlConnection(strConnString)
Dim sqlda As SqlDataAdapter
Dim com As SqlCommand
Dim ds As
DataSet
Dim str AsString
ProtectedSub Page_Load(ByVal
sender AsObject,
ByVal e As
System.EventArgs) HandlesMe.Load
IfNot
IsPostBack Then
bindgrid("sname")
EndIf
EndSub
Sub bindgrid(ByVal s AsString)
Try
con.Open()
str = "select * from
student order by " & s
com = New
SqlCommand(str, con)
Dim reader As SqlDataReader = com.ExecuteReader
DataGrid1.DataSource = reader
DataGrid1.DataBind()
con.Close()
Catch ex As Exception
MsgBox(ex.Message)
EndTry
EndSub
ProtectedSub DataGrid1_SortCommand(ByVal
source AsObject,
ByVal e As
System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles DataGrid1.SortCommand
Join the conversation! Your thoughts help the community grow.