The GridView 'GridViewID' fired event PageIndexChanging which wasn't handled.
The GridView 'GridViewID' fired event Sorting which wasn't handled.
private string ConvertSortDirectionToSql(SortDirection sortDirection)
{
string newSortDirection = String.Empty;
switch (sortDirection)
{
case SortDirection.Ascending:
newSortDirection = "ASC";
break;
case SortDirection.Descending:
newSortDirection = "DESC";
break;
}
return newSortDirection;
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
GridViewSortExpression = e.SortExpression;
int pageIndex = this.GridView1.PageIndex;
this.GridView1.DataSource = SortDataTable(GridView1.DataSource as DataTable, false);
this.GridView1.DataBind();
this.GridView1.PageIndex = pageIndex;
}
private string GridViewSortDirection
{
get
{
return ViewState["SortDirection"] as string ?? "ASC";
}
set
{
ViewState["SortDirection"] = value;
}
}
private string GridViewSortExpression
{
get
{
return ViewState["SortExpression"] as string ?? string.Empty;
}
set
{
ViewState["SortExpression"] = value;
}
}
private string GetSortDirection()
{
switch (GridViewSortDirection)
{
case "ASC":
GridViewSortDirection = "DESC";
break;
case "DESC":
GridViewSortDirection = "ASC";
break;
}
return GridViewSortDirection;
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
this.GridView1.DataSource = SortDataTable(this.GridView1.DataSource as DataTable, true);
this.GridView1.PageIndex = e.NewPageIndex;
this.GridView1.DataBind();
}
protected DataView SortDataTable(DataTable dataTable, bool isPageIndexChanging)
{
if (dataTable != null)
{
DataView dataView = new DataView(dataTable);
if (GridViewSortExpression != string.Empty)
{
if (isPageIndexChanging)
{
dataView.Sort = string.Format("{0} {1}", GridViewSortExpression, GridViewSortDirection);
}
else
{
dataView.Sort = string.Format("{0} {1}", GridViewSortExpression, GetSortDirection());
}
}
return dataView;
}
else
{
return new DataView();
}
}
Monday, March 16, 2009
How to have Display Number in GridView
< asp:TemplateField >
< ItemTemplate >
< %# Container.DataItemIndex + 1 % >
< /ItemTemplate >
< /asp:TemplateField >
< ItemTemplate >
< %# Container.DataItemIndex + 1 % >
< /ItemTemplate >
< /asp:TemplateField >
Tuesday, March 10, 2009
Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started..
The error that you are getting is because your StateServer is not enabled. You have to go to AdministrativeTools > Computer Management > Services and Applications >Services and start the ASP.NET State Service
The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported...
This problem frequently occurs when you just restored a database, but service brokers are broken or lost.
To resolve this problem.
alter database xxxx set NEW_BROKER
Alternatively,
1. Go to Programs -> Microsoft Sql Server 2005 -> Configuration Tools -> Sql Server Surface Area Configuration -> Surface Area Configuration for Features.
2. Locate "Service Broker" under the database engine and enable it.
To resolve this problem.
alter database xxxx set NEW_BROKER
Alternatively,
1. Go to Programs -> Microsoft Sql Server 2005 -> Configuration Tools -> Sql Server Surface Area Configuration -> Surface Area Configuration for Features.
2. Locate "Service Broker" under the database engine and enable it.
Sunday, March 08, 2009
Could not load file or assembly 'System.Web.Abstractions, Version=3.5.0.0, Culture=neutral,
To resolve this problem
1. Download and Install .NET Framework 3.5 SP1 at
http://www.microsoft.com/downloads/thankyou.aspx?familyId=ab99342f-5d1a-413d-8319-81da479ab0d7&displayLang=en
2. Download and install ASP.NET MVC Release Candidate 2
http://www.microsoft.com/downloads/details.aspx?FamilyID=ee4b2e97-8a72-449a-82d2-2f720d421031&displaylang=en#filelist
3. Check that the 3 dlls are in the bin folder. Your application should work ;)
System.Web.Abstractions
System.Web.Routing
System.Web.Mvc
1. Download and Install .NET Framework 3.5 SP1 at
http://www.microsoft.com/downloads/thankyou.aspx?familyId=ab99342f-5d1a-413d-8319-81da479ab0d7&displayLang=en
2. Download and install ASP.NET MVC Release Candidate 2
http://www.microsoft.com/downloads/details.aspx?FamilyID=ee4b2e97-8a72-449a-82d2-2f720d421031&displaylang=en#filelist
3. Check that the 3 dlls are in the bin folder. Your application should work ;)
System.Web.Abstractions
System.Web.Routing
System.Web.Mvc
Subscribe to:
Posts (Atom)