Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Refresh Problem? 1

Status
Not open for further replies.

LowBrow

Technical User
Jun 1, 2001
100
US
I originally posted a note in the APS.NET forum and did not get a response that resolved my issues. I believe part of that was due to poor explaining, so I will try to give a brief but better description of my problem.
I have 3 webuser controls for my site. Each is a gridview that gives a CaseManager Name, Region Assigned, Team Assigned, and Office Assigned. Each Control appears on its own page alone. Each Control has a single dropdown list on its page.
When I run and debug the site, and navigate to one of the three pages, that page will filter properly, meaning if I initially navigate to the Team list page, the and select a team from the dropdownlist, the listed CaseManagers will be accurate. However, when I navigate to Region Assigned control/page or the Office Assigned control/page, it will not. Whichever page I select FIRST, it will produce proper listings based on the selected option. BUT when you navigate to a subsequent control/page, it will not produce accurate information based on the selection from the dropdown list. Below is all code associated with these controls. Please let me know if you can offer any assistance.
Controls - CaseOffice
Code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CaseOffice_control_vs02.ascx.cs" Inherits="CaseOffice_control_vs02" %>
<%@ Import Namespace="NWC.CSWeb.UI" %>

        <asp:Literal ID="lblFilterSelect" runat="server" Text="Filter by:"></asp:Literal>
        <asp:DropDownList ID="ddlSelectOffice" runat="server" AutoPostBack="True" DataSourceID="objSelectOffice"
             DataTextField="CaseOfficeDesc" DataValueField="ID" AppendDataBoundItems="True">
        <asp:ListItem Value="0">All Offices</asp:ListItem>  
        </asp:DropDownList><asp:ObjectDataSource ID="objSelectOffice" runat="server" SelectMethod="GetCaseOfficeLocations"
            TypeName="NWC.CSWeb.BLL.Program.CaseOfficeLocation">
        </asp:ObjectDataSource>
        <br />
        <asp:GridView ID="gvwOfficeCseMgrs" runat="server" AllowPaging="True" AutoGenerateColumns="False"
             DataSourceID="objOfficeCseMgrs" />
            <Columns>
                <asp:HyperLinkField DataTextField="Title" HeaderText="Name" NavigateUrl="~/ShowCaseManager.aspx" />
                <asp:BoundField DataField="CaseOffice" HeaderText="CaseOffice" SortExpression="CaseOffice" />
                <asp:BoundField DataField="CaseRegion" HeaderText="CaseRegion" SortExpression="CaseRegion" />
                <asp:BoundField DataField="CaseTeam" HeaderText="CaseTeam" SortExpression="CaseTeam" />
                <asp:CommandField ShowEditButton="True" />
                <asp:CommandField ShowDeleteButton="True" />
            </Columns>

        </asp:GridView>
        <asp:ObjectDataSource ID="objOfficeCseMgrs" runat="server" SelectMethod="GetOfficeCaseManagers"
            TypeName="NWC.CSWeb.BLL.Program.CaseManager">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlSelectOffice" DefaultValue="0" Name="caseOffID"
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>
Controls - CaseRegion
Code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CaseRegion_control_vs02.ascx.cs" Inherits="CaseRegion_control_vs02" %>
<%@ Import Namespace="NWC.CSWeb.UI" %>

        <asp:Literal ID="lblFilterSelect" runat="server" Text="Select Filter:"></asp:Literal>
        <asp:DropDownList ID="ddlSelectRegion" runat="server" AppendDataBoundItems="True"
             AutoPostBack="True" DataSourceID="objSelectCaseRegions" DataTextField="RegionDesc"
             DataValueField="ID">
        <asp:ListItem Value="0">All Regions</asp:ListItem>          
        </asp:DropDownList><asp:ObjectDataSource ID="objSelectCaseRegions" runat="server"
            SelectMethod="GetCaseRegions" TypeName="NWC.CSWeb.BLL.Program.CaseRegion">
        </asp:ObjectDataSource>
        <br />
        <asp:GridView ID="gvwRegionCseMgrs" runat="server" AllowPaging="True" AutoGenerateColumns="False"
             DataSourceID="objRegionCseMgrs" />
            <Columns>
                <asp:HyperLinkField DataTextField="Title" HeaderText="Name" />
                <asp:BoundField DataField="CaseRegion" HeaderText="CaseRegion" SortExpression="CaseRegion" />
                <asp:BoundField DataField="CaseOffice" HeaderText="CaseOffice" SortExpression="CaseOffice" />
                <asp:BoundField DataField="CaseTeam" HeaderText="CaseTeam" SortExpression="CaseTeam" />
                <asp:CommandField ShowEditButton="True" />
                <asp:CommandField ShowDeleteButton="True" />
            </Columns>

        </asp:GridView>
        <asp:ObjectDataSource ID="objRegionCseMgrs" runat="server" SelectMethod="GetRegionCaseManagers"
            TypeName="NWC.CSWeb.BLL.Program.CaseManager">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlSelectRegion" DefaultValue="0" Name="caseRegionID"
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>
Controls - CaseTeam
Code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CaseTeam_control_vs02.ascx.cs" Inherits="CaseTeam_control_vs02" %>
<%@ Import Namespace="NWC.CSWeb.UI" %>

<asp:Literal ID="lblFilterSelect" runat="server" Text="Filter by Team:"></asp:Literal>
        <asp:DropDownList ID="ddlSelectTeam" runat="server" AppendDataBoundItems="True"
            AutoPostBack="True" DataSourceID="objSelectCaseTeam" DataTextField="CaseTeamDesc"
            DataValueField="ID">
        <asp:ListItem Value="0">All Teams</asp:ListItem>
        
        </asp:DropDownList><asp:ObjectDataSource ID="objSelectCaseTeam" runat="server" SelectMethod="GetCaseTeams"
            TypeName="NWC.CSWeb.BLL.Program.CaseTeam"></asp:ObjectDataSource>
        <br />
        <asp:GridView ID="gvwTeamCseMgrs" runat="server" AllowPaging="True" AutoGenerateColumns="False"
             DataSourceID="objTeamCseMgrs" >
            
            <Columns>
                <asp:HyperLinkField DataTextField="Title" HeaderText="Name" />
                <asp:BoundField DataField="CaseOffice" HeaderText="CaseOffice" SortExpression="CaseOffice" />
                <asp:BoundField DataField="CaseRegion" HeaderText="CaseRegion" SortExpression="CaseRegion" />
                <asp:BoundField DataField="CaseTeam" HeaderText="CaseTeam" SortExpression="CaseTeam" />
                <asp:CommandField ShowEditButton="True" />
                <asp:CommandField ShowDeleteButton="True" />
            </Columns>
        </asp:GridView>
        <asp:ObjectDataSource ID="objTeamCseMgrs" runat="server" SelectMethod="GetTeamCaseManagers"
            TypeName="NWC.CSWeb.BLL.Program.CaseManager">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlSelectTeam" DefaultValue="0" Name="caseTeamID"
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>
Control Bindings
Code:
namespace NWC.CSWeb.UI.Controls
{
    public partial class CaseOffice_control_vs02 : BaseWebPart
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // hide the columns for editing and deleting a client if the current user
            // is not an Administrator or a Program Coordinator
            bool userCanEdit = (this.Page.User.Identity.IsAuthenticated &&
               (this.Page.User.IsInRole("Administrators") || this.Page.User.IsInRole("ProgCoors")));
            gvwOfficeCseMgrs.Columns[4].Visible = userCanEdit;
            gvwOfficeCseMgrs.Columns[5].Visible = userCanEdit;
        }


        protected void ddlSelectOffice_SelectedIndexChanged(object sender, EventArgs e)
        {

            gvwOfficeCseMgrs.DataBind();
        }
    }
}

namespace NWC.CSWeb.UI.Controls
{
    public partial class CaseRegion_control_vs02 : BaseWebPart
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // hide the columns for editing and deleting a client if the current user
            // is not an Administrator or a Program Coordinator
            bool userCanEdit = (this.Page.User.Identity.IsAuthenticated &&
               (this.Page.User.IsInRole("Administrators") || this.Page.User.IsInRole("ProgCoors")));
            gvwRegionCseMgrs.Columns[4].Visible = userCanEdit;
            gvwRegionCseMgrs.Columns[5].Visible = userCanEdit;
        }

        protected void ddlCaseRegions_SelectedIndexChanged(object sender, EventArgs e)
        {

            gvwRegionCseMgrs.DataBind();
        }
    }
}

namespace NWC.CSWeb.UI.Controls
{
    public partial class CaseTeam_control_vs02 : BaseWebPart
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            // hide the columns for editing and deleting a client if the current user
            // is not an Administrator or a Program Coordinator
            bool userCanEdit = (this.Page.User.Identity.IsAuthenticated &&
               (this.Page.User.IsInRole("Administrators") || this.Page.User.IsInRole("ProgCoors")));
            gvwTeamCseMgrs.Columns[4].Visible = userCanEdit;
            gvwTeamCseMgrs.Columns[5].Visible = userCanEdit;
        }

        protected void ddlSelectTeam_SelectedIndexChanged(object sender, EventArgs e)
        {

            gvwTeamCseMgrs.DataBind();
        }
    }
}
Collection Definitions
Code:
       /// <summary>
        /// Returns a collection with all Case Managers for the Specified Team
        /// </summary>

        public static List<CaseManager> GetTeamCaseManagers(int caseTeamID)
        {
            if (caseTeamID <= 0)
                return GetCaseManagers();

            List<CaseManager> caseManagers = null;
            string key = "Program_CaseManagers_" + caseTeamID.ToString();

            if (BaseProgram.Settings.EnableCaching && BizObject.Cache[key] != null)
            {
                caseManagers = (List<CaseManager>)BizObject.Cache[key];
            }
            else
            {
                List<CaseManagerDetails> recordset = SiteProvider.Program.GetTeamCaseManagers(caseTeamID);
                caseManagers = GetCaseManagerListFromCaseManagerDetailsList(recordset);
                BaseProgram.CacheData(key, caseManagers);
            }
            return caseManagers;
        }

        /// <summary>
        /// Returns a collection with all Case Managers for the Specified Office
        /// </summary>

        public static List<CaseManager> GetOfficeCaseManagers(int caseOffID)
        {
            if (caseOffID <= 0)
                return GetCaseManagers();

            List<CaseManager> caseManagers = null;
            string key = "Program_CaseManagers_" + caseOffID.ToString();

            if (BaseProgram.Settings.EnableCaching && BizObject.Cache[key] != null)
            {
                caseManagers = (List<CaseManager>)BizObject.Cache[key];
            }
            else
            {
                List<CaseManagerDetails> recordset = SiteProvider.Program.GetOfficeCaseManagers(caseOffID);
                caseManagers = GetCaseManagerListFromCaseManagerDetailsList(recordset);
                BaseProgram.CacheData(key, caseManagers);
            }
            return caseManagers;
        }

        /// <summary>
        /// Returns a collection with all Case Managers for the Specified Region
        /// </summary>

        public static List<CaseManager> GetRegionCaseManagers(int caseRegionID)
        {
            if (caseRegionID <= 0)
                return GetCaseManagers();

            List<CaseManager> caseManagers = null;
            string key = "Program_CaseManagers_" + caseRegionID.ToString();

            if (BaseProgram.Settings.EnableCaching && BizObject.Cache[key] != null)
            {
                caseManagers = (List<CaseManager>)BizObject.Cache[key];
            }
            else
            {
                List<CaseManagerDetails> recordset = SiteProvider.Program.GetRegionCaseManagers(caseRegionID);
                caseManagers = GetCaseManagerListFromCaseManagerDetailsList(recordset);
                BaseProgram.CacheData(key, caseManagers);
            }
            return caseManagers;
        }
SQL Provider Calls
Code:
        /// <summary>
        /// Retrieves all Case Managers for the specified Office Location 
        /// </summary>
        public override List<CaseManagerDetails> GetOfficeCaseManagers(int caseOffID)
        {
            using (SqlConnection cn = new SqlConnection(this.ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("nwc_Program_GetCaseManagersByOffice", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@CaseOffID", SqlDbType.Int).Value = caseOffID;

                cn.Open();
                return GetCaseManagerCollectionFromReader(ExecuteReader(cmd), false);
            }
        }

        /// <summary>
        /// Retrieves all Case Managers for the specified Region 
        /// </summary>
        public override List<CaseManagerDetails> GetRegionCaseManagers(int caseRegionID)
        {
            using (SqlConnection cn = new SqlConnection(this.ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("nwc_Program_GetCaseManagersByRegion", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@CaseRegionID", SqlDbType.Int).Value = caseRegionID;

                cn.Open();
                return GetCaseManagerCollectionFromReader(ExecuteReader(cmd), false);
            }
        }

        /// <summary>
        /// Retrieves all Case Managers for the specified Team 
        /// </summary>
        public override List<CaseManagerDetails> GetTeamCaseManagers(int caseTeamID)
        {
            using (SqlConnection cn = new SqlConnection(this.ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("nwc_Program_GetCaseManagersByTeam", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@CaseTeamID", SqlDbType.Int).Value = caseTeamID;

                cn.Open();
                return GetCaseManagerCollectionFromReader(ExecuteReader(cmd), false);
            }
        }
 
your cache keys all have the same name: [tt]"Program_CaseManagers_" + #[/tt]. Change the name of the cache keys to something like
[tt]Region_CaseManagers_ + #[/tt] for regions
[tt]Office_CaseManagers_ + #[/tt] for offices
[tt]Team_CaseManagers_ + #[/tt] for teams

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thank you so much! I didn't realize that the key names would cause this issue. It makes sense now that I think about it. And more importantly, IT WORKS! Thank again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top