problem in grid view
-
iam using a grid view in a tab screen
iam sorting tat grid if i click the column header as if i click one time it is ascending and another time it is descending...my problem is :
i)when i mouse over the column heading it is under lined(like the anchor link) is there any way to avoid it?
ii) and if i click the column heading the grid header gets expanded..i dont know why it is doing so....i attached my screen shots
my codind is:
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ACT" %><%
@ Register Namespace="Unisys.TM.CRMWebControls" TagPrefix="UCC" %><
asp:PlaceHolder ID="TeamName" runat="server"> <div class="collapsePanelHeader">Unassigned Team Work:
<UCC:Label runat="server" ID="lblTeamName" /></div></
asp:PlaceHolder><
ACT:TabContainer ID="unassignedWork" AutoPostBack="true" runat="server" ActiveTabIndex="0" CssClass="ajax__tab_technorati-theme"> <ACT:TabPanel ID="tabSteps" runat="server" HeaderText="tabSteps"> <ContentTemplate> <div class="collapsePanelHeader"> <asp:UpdatePanel ID="upStepsRB" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="False"> <ContentTemplate> </ContentTemplate> </asp:UpdatePanel> </div> <div class="content"> <asp:UpdatePanel ID="upSteps" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="False"> <ContentTemplate> <UCC:GridView ID="stepsGrid" runat="server" Width="100%" GridLines="None" EnableViewState="false" HeaderStyle-CssClass="GridViewHeader" DataKeyNames="TaskID" AllowPaging="true"PageSize="10" CssClass="GridView" OnPageIndexChanging="StepsGrid_PageIndexChanging" AllowSorting="true" AutoGenerateColumns="false" > <AlternatingRowStyle BackColor="#FBF5F6" /> <Columns> <asp:TemplateField>Steps for others
</HeaderTemplate> </ACT:TabPanel>and aspx.cs:
using
System;using
System.Data;using
System.Configuration;using
System.Collections;using
System.Web;using
System.Web.Security;using
System.Web.UI;using
System.Web.UI.WebControls;using
System.Web.UI.WebControls.WebParts;using
System.Web.UI.HtmlControls;using
Unisys.TM.UICommon.Helper;using
Unisys.TM.CRMServices;using
Resources;using
Unisys.TM.Resource;using
Unisys.TM.CRMEntities;using
Unisys.TM.Framework.TMException;using
System.Xml.XPath;public partial class unassignedTabContainer : Unisys.CRM.BaseForm.BaseCRMControlClass{
public System.Int32 ContactsPage{
get { return System.Convert.ToInt32(Unisys.TM.UICommon.Helper.SessionManager.GetSession("ContactsPage")); }set { Unisys.TM.UICommon.Helper.SessionManager.SetSession("ContactsPage", value); }}
public System.Int32 TasksPage{
get { return System.Convert.ToInt32(Unisys.TM.UICommon.Helper.SessionManager.GetSession("TasksPage")); }set { Unisys.TM.UICommon.Helper.SessionManager.SetSession("TasksPage", value); }}
// Added By Keane for CR-Beginpublic System.Int32 StepsPage{
get { return System.Convert.ToInt32(Unisys.TM.UICommon.Helper.SessionManager.GetSession("StepsPage")); }set { Unisys.TM.UICommon.Helper.SessionManager.SetSession("StepsPage", value); }}
// Added By Keane for CR-End#region
OnInit#region
// Modified By: Keane Inc.#endregion
/// <summary> /// OnInit Page /// </summary> /// <param name="e">EventArgs</param>protected override void OnInit(EventArgs e){
base.OnInit(e); //Start of Keane modificationScriptManager scriptManager;
string hdnField = string.Empty;scriptManager = ScriptManager.GetCurrent(
Page);hdnField =
"var hdnRowValue='" + this.hdnRowValue.ClientID + "'; "+
"var hdnReassignUserID ='" + this.hdnReassignUserID.ClientID + "'; "+
"var hdnReassignUserName ='" + this.hdnReassignUserName.ClientID + "'; "+ "var hdnReassignUserType ='" + this.hdnReassignUserType.ClientID + "'; ";ScriptManager.RegisterClientScriptBlock(
this.upSteps, this.upSteps.GetType(), "hdnField", hdnField, true);string roleString =}
#endregion
protected void Page_Load(object sender, EventArgs e){
if (!this.ctlPostback){
lblTeamName.value = Unisys.TM.UICommon.Helper.SessionManager.UserData.UserTeamName;
ContactsPage = 0;
TasksPage = 0;
// Added By Keane for CR-BeginStepsPage = 0;
// Added By Keane for CR-End}
LoadTabContent(unassignedWork);
taskGrid.SelectedIndexChanged += new EventHandler(TaskGrid_SelectedIndexChanged); // Added By Keane for CR-BeginstepsGrid.SelectedIndexChanged += new EventHandler(StepsGrid_SelectedIndexChanged);stepsGrid.Sorting +=
new GridViewSortEventHandler(StepsGrid_Sorting); // Added By Keane for CR-End}
private void LoadTabContent(AjaxControlToolkit.TabContainer container){
string tabName = ((container.ActiveTab.ID.ToString() == string.Empty) || (container.ActiveTab.ID.ToString() == null)) ? ("tabTasks") : (container.ActiveTab.ID.ToString());switch (tabName){
case "tabTasks":taskGrid.ShowableFields.Add("PlanType", "TASK TYPE"); //Modified by Keane - CR #1 - StarttaskGrid.ShowableFields.Add("ClientID", "ClientID"); //Modified by Keane - CR #1 - EndtaskGrid.ShowableFields.Add("ClientName", "CLIENT NAME");taskGrid.ShowableFields.Add(
"TaskID", "TASK ID");taskGrid.ShowableFields.Add("PlanName", "TASK NAME");taskGrid.ShowableFields.Add(
"StatusDate", "STATUS DATE");taskGrid.ShowableFields.Add("CurrentStepName", "CURRENT STEP");taskGrid.ShowableFields.Add(
"CurrentStepStatus", "STEP STATUS");taskGrid.ShowableFields.Add("EstmCompDate", "END DATE"); // Added by Keane for CR #1 - StarttaskGrid.ShowableFields.Add("ClientType", "Client Type"); // Added by Keane for CR #1 - EndtaskGrid.Initialize("taskGrid", null);Unisys.TM.CRMServices.SvcTask svcTasks = new Unisys.TM.CRMServices.SvcTask();taskGrid.DataSource = svcTasks.GetUnassignedTasks(Unisys.TM.UICommon.Helper.SessionManager.UserData.UserTeam);
taskGrid.DataBind();
//Modified by Keane - CR #1 - StarttaskGrid.Columns[2].Visible = false; //Modified by Keane - CR #1 - EndupTasks.Update();
break; case "tabReferrals": //TODO Iteracion IIbreak; case "tabSteps": // Added By Keane for CR-Begin //for (int i = stepsGrid.Columns.Count - 1; i >= 1; i--) // stepsGrid.Columns.RemoveAt(i); // Unisys.TM.CRMServices.SvcTask svcTasksStep = new Unisys.TM.CRMServices.SvcTask(); //Unisys.TM.CRMEntities.Steps steps = new Unisys.TM.CRMEntities.Steps();ViewState["sortExpr"] = null;stepsGrid.DataSource = stepsBind();
stepsGrid.DataBind();
upSteps.Update();
upStepsRB.Update();
// Added By Keane for CR-Endbreak;}
}
#region TaskGrid_SelectedIndexChanged /// <summary> /// This function gets triggered when a row is seleted from the taskgrid. /// and depending on the selected row client search is done and if it is success it will navigate to /// Task step view page /// </summary> /// <param name="sender">object</param> /// <param name="e">Event Arguments</param>protected void TaskGrid_SelectedIndexChanged(object sender, EventArgs e){
//Modified By Keane - CR #1 - Start try{
string clientID = string.Empty; string taskId = string.Empty;string planName = string.Empty; string clientType = string.Empty;string instID = "1001"; string clientNotice = "Client not found.";string individualType = "I";string organizationType = "O";Clients clients;
ClientSearchCriteria clientSearch;
SvcClient svcClient;
SessionManager sessionMgr;
int rowValueID = taskGrid.SelectedIndex;if (rowValueID >= 0){
clientID = taskGrid.Rows[rowValueID].Cells[2].Text;
taskId = taskGrid.Rows[rowValueID].Cells[4].Text;
planName = taskGrid.Rows[rowValueID].Cells[5].Text;
clientType = taskGrid.Rows[rowValueID].Cells[10].Text;
//client searchclientSearch = new ClientSearchCriteria();clientSearch.Account = string.Empty;clientSearch.CIF = clientID;
svcClient =
new SvcClient();clients = new Clients();if (clientType.Equals(individualType)){
clients = svcClient.SearchClients(0, clientSearch, instID, 1);
}
else if (clientType.Equals(organizationType)){
clients = svcClient.SearchClients(1, clientSearch, instID, 1);
}
if (clients.Count == 0){
base.RaiseStatuBarEvent(this, new StatusBarEventArgs(clientNotice));return;}
else{
AddActiveClient(clients[0]);
SessionManager.SetSession("PlanName", planName);sessionMgr = new SessionManager();sessionMgr.TaskID = taskId;
base.NavigateTo(PAGELOCATION.TASK_STEP_VIEW);}
}
}
catch(Exception ex){
if (ExceptionPolicy.HandleException(ex, RSLOGEXCP.UIPOLICY)){
throw;}
}
//Modified By Keane - CR #1 - End}
#endregion
// Added By Keane for CR-Begin#region StepsGrid_SelectedIndexChanged Method /// <summary> /// Function to execute on the change of index /// </summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param>protected void StepsGrid_SelectedIndexChanged(object sender, EventArgs e){
XPathNavigator xPathNav; XPathDocument xPathDoc;string clientID = string.Empty; string clientType = string.Empty;string instID = string.Empty; string clientNotice = "Client not found.";string individualType = "I";string organizationType = "O";ClientSearchCriteria clientSearch;
SvcClient svcClient;
Clients clients=new Clients();SessionManager sessionMgr=
new SessionManager();int rowValueID = stepsGrid.SelectedIndex; string taskId = stepsGrid.Rows[rowValueID].Cells[3].Text;string stepName = stepsGrid.Rows[rowValueID].Cells[5].Text; string planName=stepsGrid.Rows[rowValueID].Cells[4].Text;bool c = false; const string NAVRUN_XPATH = "runtimeConfigurationLibrary/institutions/institution[@name='";xPathDoc = new XPathDocument(ConfigurationManager.AppSettings["NavRunPath"]);xPathNav = xPathDoc.CreateNavigator();
instID = xPathNav.SelectSingleNode
(NAVRUN_XPATH + ConfigurationManager.AppSettings[SRTMNet.InstitutionName] + "']").GetAttribute("id", "");sessionMgr.TaskID = taskId;
sessionMgr.StepName = stepName;
if (SessionManager.StepForOtherName.Equals(SRCRM.ClaimStep)){
int index = -1;Unisys.TM.CRMServices.SvcTask taskDetails =
new Unisys.TM.CRMServices.SvcTask();Unisys.TM.CRMEntities.Task task = new Unisys.TM.CRMEntities.Task();task = taskDetails.GetDetails(taskId);
for (int i = 0; i < task.Steps.Count; i++){
if (stepName.Equals(task.Steps[i].StepName)){
index = i;
}
}
if (index >= 0){
clientID = task.ClientID;
clientType = task.Steps[index].ClientType;
//client searchclientSearch = new ClientSearchCriteria();clientSearch.Account = string.Empty;clientSearch.CIF = clientID;
svcClient =
new SvcClient();if (clientType.Equals(individualType)){
clients = svcClient.SearchClients(0, clientSearch, instID, 1);
}
else if (clientType.Equals(organizationType)){
clients = svcClient.SearchClients(1, clientSearch, instID, 1);
}
string stepCode = task.Steps[index].StepCode; int seqNbr = System.Int32.Parse(task.Steps[index].SeqNbr);string ownerID = SessionManager.UserData.TellerID;Unisys.TM.CRMSupport.Service.SearchType searchType = Unisys.TM.CRMSupport.Service.SearchType.User;
Unisys.TM.CRMServices.SvcTask svcTasksStep = new Unisys.TM.CRMServices.SvcTask();c = svcTasksStep.ReassignStep(taskId, stepCode, seqNbr, ownerID, searchType);
}
}
{
if (clients.Count == 0){
base.RaiseStatuBarEvent(this, new StatusBarEventArgs(clientNotice));return;}
else{
AddActiveClient(clients[0]);
SessionManager.SetSession("PlanName", planName);base.NavigateTo(PAGELOCATION.TASK_STEP_VIEW);}
}
//SessionManager.SetSession("TaskID", ((System.Web.UI.WebControls.GridView)sender).SelectedValue);}
#endregion StepsGrid_SelectedIndexChanged Method // Added By Keane for CR-Endprotected void imgCancel_Click(object sender, EventArgs e){
SessionManager.StepForOtherName = string.Empty; //lblTaskDet.Text = string.Empty;}
protected void hdnRowValue_ValueChanged(object sender, EventArgs e){
int rowIndex = Convert.ToInt32(hdnRowValue.Value); //lblTaskDet.Text = stepsGrid.Rows[rowIndex - 1].Cells[4].Text;}
#region
imgOk_Click#region
// Added By: Keane Inc.#endregion
/// <summary> /// Re-assigns referrals to the selected Users. /// </summary> /// <param name="sender"></param> /// <param name="e"></param>protected void imgOk_Click(object sender, EventArgs e){
string userName = this.hdnReassignUserName.Value; string userID = this.hdnReassignUserID.Value;string userType = this.hdnReassignUserType.Value; int rowValueID = stepsGrid.SelectedIndex;string taskId = SessionManager.GetSession("TaskID").ToString(); string stepName = SessionManager.GetSession("StepName").ToString();bool reassignResult = false; int index = -1;Unisys.TM.CRMServices.SvcTask taskDetails = new Unisys.TM.CRMServices.SvcTask();Unisys.TM.CRMEntities.Task task = new Unisys.TM.CRMEntities.Task();task = taskDetails.GetDetails(taskId);
for (int i = 0; i < task.Steps.Count; i++){
if (stepName.Equals(task.Steps[i].StepName)){
index = i;
}
}
if (index >= 0){
string stepCode = task.Steps[index].StepCode; int seqNbr = System.Int32.Parse(task.Steps[index].SeqNbr);string ownerID = userID;Unisys.TM.CRMSupport.Service.SearchType searchType = Unisys.TM.CRMSupport.Service.SearchType.User;
Unisys.TM.CRMServices.SvcTask svcTasksStep = new Unisys.TM.CRMServices.SvcTask();reassignResult = svcTasksStep.ReassignStep(taskId, stepCode, seqNbr, ownerID, searchType);
}
if (reassignResult){
SvcTask svcTasksStep = new SvcTask();Steps steps = svcTasksStep.GetUnassignedSteps(Unisys.TM.UICommon.Helper.SessionManager.UserData.UserTeam);
stepsGrid.DataSource = steps;
stepsGrid.DataBind();
upSteps.Update();
upStepsRB.Update();
}
}
public string ReassignStepPopupControl(object TaskID, object StepName){
string contextKey = string.Empty;contextKey = TaskID.ToString();
string stepName = StepName.ToString();contextKey = contextKey +
"|" + stepName;return contextKey;}
#endregion
protected void TasksGrid_PageIndexChanging(Object sender, GridViewPageEventArgs e){
if ((e.NewPageIndex == 0) || (e.NewPageIndex == 2147483647)){
taskGrid.PageIndex = e.NewPageIndex;
taskGrid.DataBind();
upTasks.Update();
}
elseif ((TasksPage + e.NewPageIndex <= taskGrid.PageCount) && (TasksPage - e.NewPageIndex > -1)){
TasksPage += e.NewPageIndex;
taskGrid.PageIndex = TasksPage;
taskGrid.DataBind();
upTasks.Update();
}
}
// Added By Keane for CR-Begin#region StepsGrid_PageIndexChanging Method /// <summary> /// This is used for page index changing /// </summary> /// <param name="sender"></param> /// <param name="e"></param>protected void StepsGrid_PageIndexChanging(Object sender, GridViewPageEventArgs e){
if (e.NewPageIndex >= 0){
StepsPage += e.NewPageIndex;
if ((e.NewPageIndex == 0) || (e.NewPageIndex == 2147483647)){
stepsGrid.PageIndex = e.NewPageIndex;
stepsGrid.DataSource = stepsBind();
stepsGrid.DataBind();
upStepsRB.Update();
upSteps.Update();
}
elseif ((StepsPage + e.NewPageIndex <= stepsGrid.PageCount) && (StepsPage - e.NewPageIndex > -1)){
stepsGrid.PageIndex = StepsPage;
stepsGrid.DataSource = stepsBind();
stepsGrid.DataBind();
upSteps.Update();
upStepsRB.Update();
}
}
}
# endregion
StepsGrid_PageIndexChanging Method#region StepsGrid_Sorting /// <summary> /// Sort for Grid /// </summary> /// <param name="sender">object</param> /// <param name="e">GridViewSortEventArgs</param>protected void StepsGrid_Sorting(object sender, GridViewSortEventArgs e){
ViewState["sortExpr"] = e.SortExpression;stepsGrid.DataSource = stepsBind();
stepsGrid.DataBind();
upSteps.Update();
upStepsRB.Update();
}
#endregion
#region
stepsBind#region
// Added By: Keane Inc.#endregion
/// <summary> /// Binds Referrals to the GridView /// </summary> /// <returns>Referrals</returns>private DataView stepsBind(){
DataTable dtsteps = new DataTable(); DataRow drsteps;DataView dvsteps;SvcTask svcTasksStep =
new SvcTask();Steps steps = new Steps();steps = svcTasksStep.GetUnassignedSteps(Unisys.TM.UICommon.Helper.SessionManager.UserData.UserTeam);
dtsteps.Columns.Add("PlanType");dtsteps.Columns.Add(
"ClientName");dtsteps.Columns.Add("TaskID");dtsteps.Columns.Add(
"PlanName");dtsteps.Columns.Add("StepName");dtsteps.Columns.Add(
"StatusDate");dtsteps.Columns.Add("StatusDesc");dtsteps.Columns.Add(
"EstmCompDate");dtsteps.Columns.Add("TaskAssignedTo");for (int i = 0; i < steps.Count; i++){
drsteps = dtsteps.NewRow();
drsteps["PlanType"] = steps[i].PlanType;drsteps[
"ClientName"] = steps[i].ClientName;drsteps["TaskID"] = steps[i].TaskID;drsteps[
"PlanName"] = steps[i].PlanName;drsteps["StepName"] = steps[i].StepName;drsteps[
"StatusDate"] = steps[i].StatusDate;drsteps["StatusDesc"] = steps[i].StatusDesc;drsteps[
"EstmCompDate"] = steps[i].EstmCompDate;drsteps["TaskAssignedTo"] = steps[i].TaskAssignedTo;dtsteps.Rows.Add(drsteps);
}
if (ViewState["sortExpr"] != null){
dvsteps = new DataView(dtsteps);dvsteps.Sort = (string)ViewState["sortExpr"] + " " + getdir(ViewState["sortExpr"].ToString()) ;}
else{
dvsteps = dtsteps.DefaultView;
}
return dvsteps;}
#endregion
private string getdir(string se){
string lastSort = ViewState["lastSort"] == null ? "ID" : (string)ViewState["lastSort"]; string lastDirection = ViewState["lastDirection"] == null ? "ASC" : (string)ViewState["lastDirection"];if (string.Compare(lastSort, se, true) == 0){
if (lastDirection == "ASC")ViewState[
"lastDirection"] = "DESC"; elseViewState["lastDirection"] = "ASC";}
elseViewState["lastDirection"] = "ASC";ViewState[
"lastSort"] = se;return (string)ViewState["lastDirection"];}
}
Post a reply
ASP.NET forum discussion
-
How to get Hotmail Contacts
by salihagenter (5 replies)
-
How to send fax using VB.net
by Jeffry Clyde (35 replies)
-
Difference between class and interface
by aladanh.go (47 replies)
-
How to Add Text in Footer of Gridview?
by arthurmarsh (5 replies)
-
Using FedEx Web Service to Calculcate Shipping Cost
by ravialen3782 (8 replies)
ASP.NET tutorials
- The Evolution of a Azure Web Application
- Protecting your ASP.NET Web API using OAuth2 and the Windows Azure Access Control Service
- Using HTML5 History in an ASP.NET MVC Site
- An Introduction to testing with the Model-View-Presenter pattern for Web Forms Development
- Improving Web Site Performance and Scalability while saving money
Quick links
Recent activity
- arif ahmad replied to How to receive data in web ...
- William Thompson replied to What is the name of the Win...
- Sameera Piyadigamage replied to Point of Sale Developers: H...
- Scott Carline replied to 4 x C# Developers for large...
- Rajendra Dhakal replied to Restore SQL Server text dat...
- cloud rainda replied to How to convert between TS f...
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).