-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: Iamtheoneurwarnedabout
Message 4 in Discussion
Hi Venkateshwari,
You can try out this way.
Set AllowSorting property of DataGrid to TRUE
private void Page_Load(object sender, System.EventArgs e)
{
//Your Connection to Backend happens here
if (!IsPostBack)
{
//.. finally bind it.
DataGrid1.DataBind();
ConXn.Close();
}
}
Goto Design mode of Datagrid1 and add event handler to the page or you can also do
manually in the following way:
Add the below line of code in public void InitializeComponent() method in your code
behind.
this.DataGrid1.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.DataGrid1_SortCommand_1);
private void DataGrid1_SortCommand_1(object source,
System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
dtView.Sort = e.SortExpression;
// DataGrid dg = source;
string strSort, strASC;
strSort = DataGrid1.Attributes["SortExpression"];
strASC = DataGrid1.Attributes["SortASC"];
DataGrid1.Attributes["SortExpression"] = e.SortExpression;
DataGrid1.Attributes["SortASC"] = "yes";
if (e.SortExpression == strSort)
{
if (strASC == "yes")
DataGrid1.Attributes["SortASC"] = "no";
else
DataGrid1.Attributes["SortASC"] = "yes";
}
dtView.Sort = DataGrid1.Attributes["SortExpression"];
if(DataGrid1.Attributes["SortASC"] == "no")
{
dtView.Sort += " DESC";
}
DataGrid1.DataBind();
}
Compile and run the application.
Note: This is an web based application.
Hope this helps you. Pls do let me know if this has solved your purpose.
Regards,
Arshad
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]