I'm create a HelpDesk project.In this i'm show all the ticket's according to status(Pending/Resolved).In one column im show ticket subject and Ticket Detail.when i'm click on any column for sorting then my gridview not show any data.but again when click on button then that is show the sorted data.It's also happens in paging.
so please any one tell the way that i'm able to sort the ticket and also paging is work.I'm attached code please find...
using
System;
using
System.Collections;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
DotNetNuke.Entities.Modules;
using
DotNetNuke.Entities.Modules.Definitions;
using
DotNetNuke.Entities.Users;
using
DotNetNuke.Security.Permissions;
using
Mandeeps.HelpDesk.Base.Library.Data;
using
Telerik.Web.UI;
namespace
Mandeeps.DNN.Modules.HelpDesk
{
public partial class DnnHelpDesk : PortalModuleBase
{
Mandeeps.HelpDesk.Base.Library.
HelpDesk lhd;
ModuleSecurity ms;
protected void Page_Load(object sender, EventArgs e)
{
ms =
new ModuleSecurity(this.ModuleConfiguration);
InitModulePermissions();
Mandeeps.DNN.Modules.HelpDesk.Data.
HelpdeskSettingDataContext context = new Modules.HelpDesk.Data.HelpdeskSettingDataContext(DotNetNuke.Common.Utilities.Config.GetConnectionString());
foreach (Mandeeps.DNN.Modules.HelpDesk.Data.HelpdeskSetting h in context.HelpdeskSettings)
{
lhd =
new Mandeeps.HelpDesk.Base.Library.HelpDesk(DotNetNuke.Common.Utilities.Config.GetConnectionString());
lhd.Pop3 =
new Mandeeps.HelpDesk.Base.Library.Mail.Pop3(h.Pop3LicenseKey, h.Pop3Server, h.Pop3Username, h.Pop3Password);
lhd.Smtp =
new Mandeeps.HelpDesk.Base.Library.Mail.Smtp(h.SmtpLicenseKey, h.SmtpServer, h.SmtpUsername, h.SmtpPassword);
lhd.Smtp.ServerPort = 2525;
lhd.PortalId = PortalId;
}
if(!IsPostBack)
Initilize();
}
public void Initilize()
{
List<Ticket> tic=null;
if(ms.IsOperator)
{
rtbSetting.Visible =
false;
rtbView.Items[0].Text =
"UnAssigned Tickets";
rtbView.Items[0].ToolTip =
"Click here for show UnAssigned Ticket's";
rtbView.Items[2].Text =
"My Tickets";
rtbView.Items[2].ToolTip =
"Click here for show Self Assigned Ticket's";
rtbView.Items[3].Visible =
true;
rtbView.Items[4].Visible =
true;
rgTicket.Columns[3].Visible =
true;
tic = lhd.GetAllOpenTickets(
null, UserId);
if (tic.Count == 0)
{
tic = lhd.GetAllUnassignedTickets();
((rtbView.Items[0])
as RadToolBarButton).Checked = true;
}
else
((rtbView.Items[2])
as RadToolBarButton).Checked = true;
}
else
tic = lhd.GetAllOpenTickets(UserId);
rgTicket.DataSource = tic;
rgTicket.DataBind();
}
protected void rtbSetting_ButtonClick(object sender, RadToolBarEventArgs e)
{
if (e.Item.Text == "Add New Ticket")
Response.Redirect(EditUrl(
"AddNewTicket"));
}
protected void rtbView_ButtonClick(object sender, RadToolBarEventArgs e)
{
List<Ticket> ticket = new List<Ticket>();
switch (e.Item.Text)
{
case "Pending":
{
rgTicket.Columns[6].Visible =
false;
ticket = lhd.GetAllOpenTickets(UserId);
break;
}
case "Resolved":
{
rgTicket.Columns[6].Visible =
true;
ticket = lhd.GetAllCloseTickets(UserId);
break;
}
case "UnAssigned Tickets":
{
rgTicket.Columns[4].Visible =
false;
rgTicket.Columns[6].Visible =
false;
ticket = lhd.GetAllUnassignedTickets();
break;
}
case "My Tickets":
{
rgTicket.Columns[4].Visible =
false;
rgTicket.Columns[6].Visible =
false;
ticket = lhd.GetAllOpenTickets(
null,UserId);
break;
}
case "All Tickets":
{
rgTicket.Columns[4].Visible =
true;
rgTicket.Columns[6].Visible =
false;
ticket = lhd.GetAllOpenTickets();
break;
}
}
rgTicket.DataSource = ticket;
rgTicket.DataBind();
}
protected void rgTicket_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = e.Item as GridDataItem;
TableCell title = item["Title"];
if (title != null)
{
Control ctl = title.FindControl("hlTicketDetails");
if (ctl != null)
{
HyperLink ticketDetails = ctl as HyperLink;
Label ticketId = title.FindControl("lTicketDetails") as Label;
Mandeeps.HelpDesk.Base.Library.Data.
Ticket t = item.DataItem as Mandeeps.HelpDesk.Base.Library.Data.Ticket;
ticketId.Text =
"#" + t.TicketID.ToString();
if (t.Title.Length > 25)
ticketDetails.Text = t.Title.Substring(0, 25)+
"...";
else
ticketDetails.Text = t.Title;
ticketDetails.NavigateUrl = EditUrl(
"", "", "ViewTicketDetail", "TicketID=" + t.TicketID.ToString());
}
}
}
}
public string ConcatColumns(object objText)
{
if (objText.ToString().Length > 50)
return objText.ToString().Substring(0, 50)+ "...";
else
return objText.ToString();
}
public string CategoryName(object objText)
{
if (int.Parse(objText.ToString()) == 0)
return "";
else
return lhd.GetCategoryName(int.Parse(objText.ToString()));
}
public string AssignedToName(object objText)
{
if (int.Parse(objText.ToString()) == -1)
return "";
else
{
UserController uC = new UserController();
UserInfo user = uC.GetUser(PortalId, int.Parse(objText.ToString()));
return user.DisplayName;
}
}
}
protected void rgTicket_SortCommand(object sender, GridSortCommandEventArgs e)
{
}
}
}
<%
@ Control Language="C#" AutoEventWireup="true" CodeBehind="DnnHelpDesk.ascx.cs" Inherits="Mandeeps.DNN.Modules.HelpDesk.DnnHelpDesk" %>
<%
@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<
telerik:RadToolBar ID="rtbSetting" runat="server" onbuttonclick="rtbSetting_ButtonClick" style="float:left">
<Items>
<telerik:RadToolBarButton runat="server" Text="Add New Ticket" ToolTip="Click here for Add New Ticket"/>
</Items>
</
telerik:RadToolBar>
<
telerik:RadToolBar ID="rtbView" runat="server" onbuttonclick="rtbView_ButtonClick" EnableShadows="True" style="float:right">
<Items>
<telerik:RadToolBarButton runat="server" Text="Pending" ToolTip="Click here for show Pending Ticket's" CheckOnClick="true" AllowSelfUnCheck="true" />
<telerik:RadToolBarButton runat="server" Text="Button 2" IsSeparator="True"/>
<telerik:RadToolBarButton runat="server" Text="Resolved" ToolTip="Click here for show Resolved Ticket's" CheckOnClick="true" AllowSelfUnCheck="true"/>
<telerik:RadToolBarButton runat="server" Text="Button 3" IsSeparator="True" Visible="false"/>
<telerik:RadToolBarButton runat="server" Text="All Tickets" ToolTip="Click here for show All Ticket's" Visible="false" CheckOnClick="true" AllowSelfUnCheck="true"/>
</Items>
</
telerik:RadToolBar><br style="clear:both;"/>
 
<
telerik:RadGrid ID="rgTicket" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" GridLines="None"
PageSize="4" onitemdatabound="rgTicket_ItemDataBound" Skin="Outlook" onsortcommand="rgTicket_SortCommand">
<MasterTableView>
<CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
<RowIndicatorColumn>
<HeaderStyle Width="20px"/>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"/>
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="TicketID" HeaderText="TicketID" SortExpression="TicketID" UniqueName="TicketID" Visible="False"/>
<telerik:GridTemplateColumn HeaderText="Ticket Detail" UniqueName="Title">
<ItemTemplate>
<asp:HyperLink ID="hlTicketDetails" runat="server" Text="Subject Appears Here" Font-Size="Small" ForeColor="#0000ff"/>
<asp:Label ID="lTicketDetails" runat="server" Font-Size="Smaller" style="float:right"/><br/>
<div>
<asp:Label id="Label1" runat="server" Text='<%#ConcatColumns(DataBinder.Eval(Container.DataItem,"Description")) %>' ForeColor="#6699ff"/></div>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Category" UniqueName="Title">
<ItemTemplate>
<asp:Label id="lcategory" runat="server" Text='<%#CategoryName(DataBinder.Eval(Container.DataItem,"CategoryId")) %>'/>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="Email" HeaderText="From" SortExpression="Email" UniqueName="Email" Visible="false"/>
<telerik:GridTemplateColumn HeaderText="Assigned To" UniqueName="Title" Visible="false">
<ItemTemplate>
<asp:Label id="lAssignedTo" runat="server" Text='<%#AssignedToName(DataBinder.Eval(Container.DataItem,"AssignedTo")) %>'/>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="OpenDateTime" HeaderText="Created On" SortExpression="OpenDateTime" UniqueName="OpenDateTime"/>
<telerik:GridBoundColumn DataField="CloseDateTime" HeaderText="Date Close" SortExpression="CloseDateTime" UniqueName="CloseDateTime" Visible="false"/>
</Columns>
</MasterTableView>
</
telerik:RadGrid>