Is there a way to refresh the data in my grid and display it without doing a postback?

I've written a web application in ASP .NET 3.5 [C#]. On on of my user controls, that lives on a page, I bind data to it so that the user can see. in order to refresh the data, the page does a refresh (just like the internet is designed to work). is there a way, with any scripting code/language or other code to refresh the data in the grid, display the refreshed data and not have the entire page refresh / postback?
LVL 1
Michael SterlingWeb Applications DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Hi mikesExpertExchange;

What you are looking for is to use AJAX to accomplish the requirements. Please have a look at this article, MSDN Magazine: Cutting Edge: ASP.NET AJAX and Client-side Temp...
0
guru_samiCommented:
Ajax is the way. If you are using asp.net WebForms, ASP.NET AJAX Update panel is the easiest way.
Wrap your usercontrol inside of an UpdatePanel and asp.net will take care of all ajax work for you.
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
@FernandoSoto / @guru_sami: Thank you. I'll have to dedicate more time to reading the entire article. Now that I know its possible, based on what guru_sami said above, can I simply wrap my user control in and AJAX Update panel and then,...??? what??? click a button to update the panel? Any clear cut simple examples of this. The control that lives on my usercontrol is a gridview control. below is what my code looks like...(the user control)

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="StudentsSignedInGrid.ascx.cs"
    Inherits="UserControls_StudentsSignedInGrid" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>
<asp:UpdatePanel runat="server" ID="upStudentLoginGrid" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:GridView ID="gdvStudentsSignedIn" runat="server" AutoGenerateColumns="false"
            CssClass="SignedInGrid" GridLines="None" AllowSorting="true" AllowPaging="true"
            PageSize="500" PagerStyle-HorizontalAlign="Center" OnRowDataBound="gdvStudentsSignedIn_OnRowDatabound"
            OnSorting="gdvShipments_OnSorting" PageIndex="0" OnRowCommand="gdvStudentSignedIn_OnRowCommand"
            OnPageIndexChanging="gdvStudentsSignedIn_OnPageIndexChanging">
            <Columns>
                <asp:TemplateField HeaderText="Record ID" SortExpression="1" Visible="false" ItemStyle-CssClass="StudentName">
                    <ItemTemplate>
                        <h2>
                            <asp:Label ID="lblRecordID" runat="server" CssClass="StudentNameLabel" Text='<%# Eval("InOutUid") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Student ID" SortExpression="1" ItemStyle-CssClass="StudentName" HeaderStyle-Width="75px">
                    <ItemTemplate>
                        <h2>
                            <asp:Label ID="lblAthleteUid" runat="server" CssClass="StudentNameLabel" Text='<%# Eval("AthleteUiD") %>'></asp:Label></a><h2>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="StudentName" SortExpression="2" HeaderStyle-Width="200px">
                    <ItemTemplate>
                        <div id="lblStudentIDForSnapShot">
                            <h2>
                                <asp:Label ID="lblStudentName" runat="server" Text='<%# Eval("AthleteName") %>'></asp:Label></h2>
                        </div>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Time In" SortExpression="3" HeaderStyle-Width="175px">
                    <ItemTemplate>
                        <h2>
                            <asp:Label ID="lblTimeIn" runat="server" Text='<%# Eval("TimeIn") %>'></asp:Label></h2>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Since Signed In" HeaderStyle-Width="100px" HeaderStyle-Font-Underline="true">
                    <ItemTemplate>
                        <h2>
                            <asp:Label runat="server" ID="lblSinceSignedIn" CssClass="sinceSignedIn" Text='<%# CalculateTime(Eval("TimeIn"), Eval("AthleteUid")) %>'></asp:Label></h2>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Team / Sport" SortExpression="5" HeaderStyle-Width="175px">
                    <ItemTemplate>
                        <h2>
                            <asp:Label ID="lblTeamName" runat="server" Text='<%# Eval("TeamName") %>'></asp:Label></h2>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderStyle-Width="100px">
                    <ItemTemplate>
                        <asp:LinkButton runat="server" ID="lknBtnWeeklyTotal" Text="Week Total" CommandName="FindCurrentWeekTotal"
                            CommandArgument='<%# Eval("AthleteUid") %>' CssClass="button small green" />
                    </ItemTemplate>
                </asp:TemplateField>           
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton runat="server" ID="btnSignOut" Text="Sign Out" CommandName="SignOut"
                            CommandArgument='<%# Eval("InOutUid") %>' CssClass="button small green" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <PagerSettings Mode="NextPrevious" />
            <PagerStyle CssClass="Paging" />
            <PagerTemplate>
                <div class="Paging">
                    <asp:LinkButton ID="PreviousLinkButton" runat="server" CommandArgument="Prev" CommandName="Page"
                        CssClass="PagerControl" Text="Prev"></asp:LinkButton>
                    <asp:Label ID="PageDescriptionLabel" runat="server" CssClass="PagerControl"></asp:Label>
                    <asp:LinkButton ID="NextLinkButton" runat="server" CommandArgument="Next" CommandName="Page"
                        CssClass="PagerControl" Text="Next"></asp:LinkButton>
                </div>
            </PagerTemplate>
        </asp:GridView>
    </ContentTemplate>
</asp:UpdatePanel>

Open in new window

0
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

guru_samiCommented:
So what is the issue you are facing after adding the update panel? How is the postback raised? Is the postback control outside of the UserControl?
Check the section "How UpdatePanel Controls Are Refreshed" in my previous link.
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
@guru_sami: currently, the control lives on an aspx webpage. when ever certain controls on that page are clicked that cause a postback, or that page is refreshed, a postback is caused. i don't know that i need to use a trigger, (which is an option described in the section you recommended) , how ever, i think if i can put a control on the update panel itself some how, that would do the trick. is there a way to do that?
0
guru_samiCommented:
Actually you need to put the portion that causes postback inside of an update panel.
With the code you have right now any postback that is caused from your UserControl, will not do full postback.
Any code that does postback outside of your UC(i.e. updatepanel) will do a full postback.
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
@guru_sami: this is what i've done. i've added this to my panel:

<asp:LinkButton runat="server" ID="lkbtnRefreshGrid" Text="Refresh" AutoPostBack="true" OnClick="lkbtnRefreshGrid_OnClick"></asp:LinkButton>

and this code:

    protected void lkbtnRefreshGrid_OnClick(object sender, EventArgs e)
    {
        upStudentLoginGrid.Update();
    }

but still nothing happens. no refresh. what am i doing wrong?
0
guru_samiCommented:
May be I am misunderstanding. Which problem are we dealing with:
- Page is causing full postback i.e. refreshing entire page
Or
- Something not updated after the partial postback? If this, can you explain a bit more on the scenario.
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
@guru_sami: sorry about that. what i'd like to do is only have the data in my grid control refresh, if this is possible. not the entire page. currently the controls outside of the updatepanel, outside of the usercontrol, (the controls that live on my aspx page), do a full refresh of the page. I'd like to just refresh the grid, if possible. does that help?
0
guru_samiCommented:
In addition you will have to wrap the controls in the page as well into an UpdatePanel.
Or if you have independent sections you can wrap them individually inside of an updatepanel. Something like this.
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
@guru_sami: this is how i have my updatepanel, trigger, and button for my trigger defined:

    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="lkbtnRefreshGrid" EventName="RefreshButton_Click" />
    </Triggers>
    <ContentTemplate>
        <asp:LinkButton runat="server" ID="lkbtnRefreshGrid" Text="Refresh" AutoPostBack="true"
            CssClass="button small green" OnClick="lkbtnRefreshGrid_OnClick">
        </asp:LinkButton>

here is the code for my button:

    protected void lkbtnRefreshGrid_OnClick(object sender, EventArgs e)
    {
        upStudentLoginGrid.Update();
    }

before i try the nested update panels, why am i still getting this error:

"Could not find an event named 'RefreshButton_Click' on associated control 'lkbtnRefreshGrid' for the trigger in UpdatePanel 'upStudentLoginGrid'."
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
@guru_sami: never mind, i figured that out. still, with my code looking like this:


<asp:UpdatePanel runat="server" ID="upStudentLoginGrid" UpdateMode="Conditional">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="lkbtnRefreshGrid" EventName="Click" />
    </Triggers>
    <ContentTemplate>
        <asp:LinkButton runat="server" ID="lkbtnRefreshGrid" Text="Refresh" AutoPostBack="true"
            CssClass="button small green" OnClick="lkbtnRefreshGrid_OnClick">
        </asp:LinkButton>

and my event like this:

    protected void lkbtnRefreshGrid_OnClick(object sender, EventArgs e)
    {
        upStudentLoginGrid.Update();
    }

i get nothing when i click the button. why is that?
0
guru_samiCommented:
It should be EventName="Click"
<asp:AsyncPostBackTrigger ControlID="lkbtnRefreshGrid" EventName="Click" />
0
guru_samiCommented:
i get nothing when i click the button. why is that?
Nothing means the whole page is refreshing or the GV Data is not showing?
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
i changed it, still nothing. i've got my code in debugger mode and it doesn't even stop in the onclick event of my button. not even touching the code. i don't understand.
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
well i got it to work, but it only refreshes once. any ideas why that would be?!
0
guru_samiCommented:
I am not sure. Can I see full updated code both from page and UC.
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
sure, here is my HTML:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="StudentsSignedInGrid.ascx.cs"
    Inherits="UserControls_StudentsSignedInGrid" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>
<asp:UpdatePanel runat="server" ID="upStudentLoginGrid" UpdateMode="Conditional">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="lkbtnRefreshGrid" EventName="Click" />
    </Triggers>
    <ContentTemplate>
        <asp:LinkButton runat="server" ID="lkbtnRefreshGrid" Text="Refresh" AutoPostBack="true"
            CssClass="button small green" OnClick="lkbtnRefreshGrid_OnClick">
        </asp:LinkButton>
        <asp:GridView ID="gdvStudentsSignedIn" runat="server" AutoGenerateColumns="false"
            CssClass="SignedInGrid" GridLines="None" AllowSorting="true" AllowPaging="true"
            PageSize="500" PagerStyle-HorizontalAlign="Center" OnRowDataBound="gdvStudentsSignedIn_OnRowDatabound"
            OnSorting="gdvShipments_OnSorting" PageIndex="0" OnRowCommand="gdvStudentSignedIn_OnRowCommand"
            OnPageIndexChanging="gdvStudentsSignedIn_OnPageIndexChanging">
            <Columns>
                <asp:TemplateField HeaderText="Record ID" SortExpression="1" Visible="false" ItemStyle-CssClass="StudentName">
                    <ItemTemplate>
                        <h2>
                            <asp:Label ID="lblRecordID" runat="server" CssClass="StudentNameLabel" Text='<%# Eval("InOutUid") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Student ID" SortExpression="1" ItemStyle-CssClass="StudentName"
                    HeaderStyle-Width="75px">
                    <ItemTemplate>
                        <h2>
                            <asp:Label ID="lblAthleteUid" runat="server" CssClass="StudentNameLabel" Text='<%# Eval("AthleteUiD") %>'></asp:Label></a><h2>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="StudentName" SortExpression="2" HeaderStyle-Width="200px">
                    <ItemTemplate>
                        <div id="lblStudentIDForSnapShot">
                            <h2>
                                <asp:Label ID="lblStudentName" runat="server" Text='<%# Eval("AthleteName") %>'></asp:Label></h2>
                        </div>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Time In" SortExpression="3" HeaderStyle-Width="175px">
                    <ItemTemplate>
                        <h2>
                            <asp:Label ID="lblTimeIn" runat="server" Text='<%# Eval("TimeIn") %>'></asp:Label></h2>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Since Signed In" HeaderStyle-Width="100px" HeaderStyle-Font-Underline="true">
                    <ItemTemplate>
                        <h2>
                            <asp:Label runat="server" ID="lblSinceSignedIn" CssClass="sinceSignedIn" Text='<%# CalculateTime(Eval("TimeIn"), Eval("AthleteUid")) %>'></asp:Label></h2>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Team / Sport" SortExpression="5" HeaderStyle-Width="175px">
                    <ItemTemplate>
                        <h2>
                            <asp:Label ID="lblTeamName" runat="server" Text='<%# Eval("TeamName") %>'></asp:Label></h2>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderStyle-Width="100px">
                    <ItemTemplate>
                        <asp:LinkButton runat="server" ID="lknBtnWeeklyTotal" Text="Week Total" CommandName="FindCurrentWeekTotal"
                            CommandArgument='<%# Eval("AthleteUid") %>' CssClass="button small green" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton runat="server" ID="btnSignOut" Text="Sign Out" CommandName="SignOut"
                            CommandArgument='<%# Eval("InOutUid") %>' CssClass="button small green" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <PagerSettings Mode="NextPrevious" />
            <PagerStyle CssClass="Paging" />
            <PagerTemplate>
                <div class="Paging">
                    <asp:LinkButton ID="PreviousLinkButton" runat="server" CommandArgument="Prev" CommandName="Page"
                        CssClass="PagerControl" Text="Prev"></asp:LinkButton>
                    <asp:Label ID="PageDescriptionLabel" runat="server" CssClass="PagerControl"></asp:Label>
                    <asp:LinkButton ID="NextLinkButton" runat="server" CommandArgument="Next" CommandName="Page"
                        CssClass="PagerControl" Text="Next"></asp:LinkButton>
                </div>
            </PagerTemplate>
        </asp:GridView>
    </ContentTemplate>
</asp:UpdatePanel>

Open in new window


here is my C# code: (i only included page_load and the button click event)

    protected void Page_Load(object sender, EventArgs e)
    {
        //if ( (!IsPostBack) || ( Refresh == "1"))
        //if (!IsPostBack)
            BindData();
    }


    protected void lkbtnRefreshGrid_OnClick(object sender, EventArgs e)
    {
        upStudentLoginGrid.Update();
    }

Open in new window

0
guru_samiCommented:
What does that Refresh link button do?  BindData(); is called on every postback, not sure if that's intended.
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
in my testing, I am intentionally calling Bane data every time should I not be? the Refresh link button refreshes the update panel when a person clicks on it.
0
guru_samiCommented:
To Refresh the Grid Data you will have to call BindData inside the Link click handler and in Page_Load you need to call BindData only If !Page.IsPostBack
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
I changed my code as you suggested. its still only allowing one refresh when i click the link button. is this correct

    protected void lkbtnRefreshGrid_OnClick(object sender, EventArgs e)
    {
        BindData();        
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            BindData();
    }

I noticed that it never hits my lnkbtnRefreshGrid_OnClick code after that first time.
0
guru_samiCommented:
Are you seeing any javascript errors after the first post?
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
I'm not seeing any javascript errors.
0
guru_samiCommented:
I am not sure then. The final thing I would suggest you to try is start from a simplest test page without any gridview but just an UpdatePanel with a Lable and Refresh Button.
Simply update the Label text to display the DateTime.Now.
See if that works.

Or do you have your current page up on some test server, that I can look at?
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
i did that and yes, that in fact works. i was trying not to dump all of my C# code in here, but this is the complete code behind for my control

using System;
using System.Collections.Generic;
//using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using StudyTimeTracker.Common.Domain;
using StudyTimeTracker.Public.Business;
using System.Security;

[assembly: AllowPartiallyTrustedCallers]


public partial class UserControls_StudentsSignedInGrid : System.Web.UI.UserControl
{
    private StudentListSearchArgs s_searchArgs;

    public String AccessLevel
    {
        get
        {
            return Request.QueryString["AccessLevel"];
        }
    }

    public String Refresh
    {
        get
        {
            return Request.QueryString["Refresh"];
        }
    }

    #region Enums

    internal enum StudentBaseListSortType
    {
        ByStudentUid = 1,
        ByLastName = 2,
        ByFirstName = 3,
        ByTimeIn = 4,
        BySportTeam = 5
    }

    #endregion

    public StudentListSearchArgs SearchArgs
    {
        get
        {
            if (s_searchArgs == null && ViewState["SearchArgs"] != null)
                s_searchArgs = (StudentListSearchArgs)ViewState["SearchArgs"];

            return s_searchArgs;
        }
        set
        {
            s_searchArgs = value;
            ViewState["SearchArgs"] = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        //if ( (!IsPostBack) || ( Refresh == "1"))
        if (!IsPostBack)
            BindData();
    }

    public void BindData()
    {
        StudentListBaseList studentList;

        studentList = StudentListProcessor.GetAllSignedInStudents("", SearchArgs);

        BindData(studentList);

    }

    private void BindData(StudentListBaseList studentList)
    {
        int pageSize = gdvStudentsSignedIn.PageSize;
        int currentPage = gdvStudentsSignedIn.PageIndex;
        int lastPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(studentList.Count / gdvStudentsSignedIn.PageSize)));
        int maxCount = ((currentPage + 1) * gdvStudentsSignedIn.PageSize);
        if (maxCount > studentList.Count) maxCount = studentList.Count;

        if (Session["StudentBaseListSortType"] != null)
            studentList = GetSortedStudentBaseList();

        gdvStudentsSignedIn.DataSource = studentList;
        gdvStudentsSignedIn.DataBind();

        if (studentList.Count > 0)
        {
            LinkButton prevLinkButton = (LinkButton)gdvStudentsSignedIn.BottomPagerRow.FindControl("PreviousLinkButton") as LinkButton;
            LinkButton nextLinkButton = (LinkButton)gdvStudentsSignedIn.BottomPagerRow.FindControl("NextLinkButton") as LinkButton;
            Label pageDescriptionLabel = (Label)gdvStudentsSignedIn.BottomPagerRow.FindControl("PageDescriptionLabel") as Label;
            prevLinkButton.Text = "< prev " + pageSize.ToString();
            nextLinkButton.Text = "next " + pageSize.ToString() + " >";


            prevLinkButton.Enabled = (currentPage > 0);
            nextLinkButton.Enabled = (currentPage < lastPage);
            pageDescriptionLabel.Text = String.Format("{0} to {1} of {2}", (currentPage * pageSize) + 1, maxCount, studentList.Count);
        }
    }

    protected void gdvStudentsSignedIn_OnRowDatabound(object sender, GridViewRowEventArgs e)
    {

        ///<summary>
        ///IN THE MARKUP, I CONCATENATED THE STUDENT NAME AND ID. THIS CODE WAS PUT IN PLACE TO
        ///STRIP OUT THE STUDENT NAME FOR DISPLAY. THIS WAS PART OF SOME EFFORT TO GET THE ROLLING
        ///OVER OF, OR, THE CLICKING OF THE STUDENT NAME TO SHOW THE WEEKLY CURRENT TOTAL FOR THAT
        ///STUDENT.
        ///</summary> 

        //if (e.Row.RowType == DataControlRowType.DataRow)
        //{
        //    int indxOf = 0;           
        //    LinkButton lnkbtnFindStudent = e.Row.FindControl("lnkbtnFindStudent") as LinkButton;
        //    indxOf = lnkbtnFindStudent.Text.IndexOf("-");
        //    lnkbtnFindStudent.Text = lnkbtnFindStudent.Text.Substring(0, indxOf - 1);

        //}

        if (e.Row.RowType == DataControlRowType.Header)
        {


            if (AccessLevel != "QUSuperMan")
            {
                gdvStudentsSignedIn.Columns[2].Visible = false;
                gdvStudentsSignedIn.Columns[7].Visible = false;
            }
            else
            {
                gdvStudentsSignedIn.Columns[2].Visible = true;
                gdvStudentsSignedIn.Columns[7].Visible = true;
            }

            if (Session["SessionSortType"] == null || Session["SessionSortDirection"] == null)
                return;

            StudentBaseListSortType sortType = (StudentBaseListSortType)Session["SessionSortType"];
            SortBase.SortDirection sortDir = (SortBase.SortDirection)Session["SessionSortDirection"];

            int cellIndex = -1;

            foreach (DataControlField field in gdvStudentsSignedIn.Columns)
            {

                if (field.SortExpression == Convert.ToInt32(sortType).ToString())
                {
                    cellIndex = gdvStudentsSignedIn.Columns.IndexOf(field);
                }
            }

            if (cellIndex > -1)
            {

                e.Row.Cells[cellIndex].CssClass =
                    sortDir == SortBase.SortDirection.Ascending ? "SortHeaderAsc" : "SortHeaderDesc";
            }

            SnapShotCurrentWeekTotal(gdvStudentsSignedIn.Columns[2]);
            // Ignore non-data rows
            if (e.Row.RowType != DataControlRowType.DataRow)
                return;
        }
    }

    protected void gdvShipments_OnSorting(object sender, GridViewSortEventArgs e)
    {
        StudentBaseListSortType sortType = ((StudentBaseListSortType)Convert.ToInt32(e.SortExpression));
        SortBase.SortDirection sortDir = SortBase.SortDirection.Ascending;

        if (Session["SessionSortDirection"] != null && Session["SessionSortType"] != null)
        {
            if (((StudentBaseListSortType)Session["SessionSortType"]) == sortType)
            {
                sortDir = ((SortBase.SortDirection)Session["SessionSortDirection"]);

                if (sortDir == SortBase.SortDirection.Ascending)
                    sortDir = SortBase.SortDirection.Descending;
                else
                    sortDir = SortBase.SortDirection.Ascending;
            }
        }

        Session["SessionSortDirection"] = sortDir;
        Session["SessionSortType"] = sortType;

        StudentListBaseList studentlist = GetSortedStudentBaseList();

        BindData(studentlist);

    }

    private StudentListBaseList GetSortedStudentBaseList()
    {

        StudentBaseListSortType sortType = Session["SessionSortType"] != null ? (StudentBaseListSortType)Session["SessionSortType"] : StudentBaseListSortType.ByStudentUid;
        StudentListBaseList studentList = StudentListProcessor.GetAllSignedInStudents("", SearchArgs);
        switch (sortType)
        {
            case StudentBaseListSortType.ByLastName:
                studentList.Sort(StudentListBase.LastNameComparison);
                break;
            case StudentBaseListSortType.ByStudentUid:
                studentList.Sort(StudentListBase.AthleteUidComparison);
                break;
            case StudentBaseListSortType.ByTimeIn:
                studentList.Sort(StudentListBase.TimeInComparison);
                break;

        }

        return studentList;
    }

    protected void gdvStudentSignedIn_OnRowCommand(object sender, GridViewCommandEventArgs e)
    {
        StudentSignInSignOutRec ssisor = new StudentSignInSignOutRec();
        StudentSignInSignOutRecList ssisorList = new StudentSignInSignOutRecList();

        if (e.CommandName == "SignOut")
        {
            GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
            int rowNum = Convert.ToInt32(e.CommandArgument);
            Label lbl = (Label)row.FindControl("lblAthleteUid");
            Label lblStudentName = (Label)row.FindControl("lblStudentName");

            if (!String.IsNullOrEmpty(AccessLevel))
                /*Response.Redirect(String.Format("Default.aspx?AccessLevel={1}&SignInID={0}", lbl.Text.ToString(), AccessLevel));*/
                /*FOR CREIGHTON*/
                Response.Redirect(String.Format("Default.aspx?AccessLevel={1}&SignInID={0}&SignOut=1", lbl.Text.ToString(), AccessLevel));
                /***************/
            else
                Response.Redirect(String.Format("Default.aspx?AccessLevel={0}&SignInID={1}", AccessLevel, lbl.Text.ToString()));
        }
        else if (e.CommandName == "FindCurrentWeekTotal")
        {
            GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
            /*FOR CREIGHTON*/
            //int rowNum = Convert.ToInt32(e.CommandArgument);
            string rowNum = e.CommandArgument.ToString();
            Label lbl = (Label)row.FindControl("lblAthleteUid");
            Label lblStudentName = (Label)row.FindControl("lblStudentName");
            Response.Redirect(String.Format("Default.aspx?AccessLevel={0}&FindWeekTotalFor={1}", AccessLevel, lbl.Text.ToString()));
        }
    }

    protected string CalculateTime(object timeIn, object studentId)
    {
        string strDateTime;
        string stId;
        DateTime currentDateTime;

        stId = (String)(studentId);

        DateTime signInTime = (DateTime)(timeIn);
        strDateTime = String.Format("{0:yyyy/MM/dd HH:mm:ss}", DateTime.Now.ToString());
        currentDateTime = DateTime.Parse(strDateTime);
        TimeSpan duration = new TimeSpan(0, 0, 0, 0);
        currentDateTime = currentDateTime.Add(duration);
        TimeSpan ts = currentDateTime.Subtract(signInTime);

        return ts.Days.ToString() + ":" + ts.Hours.ToString("00") + ":" + ts.Minutes.ToString("00") + ":" + ts.Seconds.ToString("00");

    }

    protected string SnapShotCurrentWeekTotal(object studentId)
    {
        string strDateTime;
        string stId;
        DateTime currentDateTime;

        stId = (String)(studentId);

        DateTime signInTime = (DateTime)(Utility.GetFirstSignInTimeForTheWeek(stId));
        strDateTime = String.Format("{0:yyyy/MM/dd HH:mm:ss}", DateTime.Now.ToString());
        //strDateTime = String.Format("{0:yyyy/MM/dd HH:mm:ss}", DateTime.UtcNow.ToString());
        currentDateTime = DateTime.Parse(strDateTime);
        TimeSpan duration = new TimeSpan(0, 3, 0, 0);
        //TimeSpan duration = new TimeSpan(0, 0, 0, 0);
        currentDateTime = currentDateTime.Add(duration);
        TimeSpan ts = currentDateTime - signInTime;

        return "<h6>Current Week Total: " + ts.Days.ToString() + ":" +
            ts.Hours.ToString("00") + ":" +
            ts.Minutes.ToString("00") + ":" +
            ts.Seconds.ToString("00") + "</h6>";

    }

    protected void gdvStudentsSignedIn_OnPageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gdvStudentsSignedIn.PageIndex = e.NewPageIndex;
        BindData();

        return;
    }

    protected void btnFindWeekTimeTotal_OnClick(object sender, EventArgs e)
    {
        
    }

    protected void lnkbtnInOutUid_OnClick(object sender, EventArgs e)
    {
         
    }

    protected void lkbtnRefreshGrid_OnClick(object sender, EventArgs e)
    {
        BindData();
        gdvStudentsSignedIn.DataBind();
    }
}

Open in new window

0
guru_samiCommented:
So you said LinkClick handler is not executed on second time correct?
Can you set a breakpoint on Page_Load and see it is exececuted.
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
On the 2nd click, the code does not make it into the Page_Load event either. Doesn't hit the if (!IsPostBack) statement at all.
0
guru_samiCommented:
Since it's working on the test page, I am not sure what else is wrong.
What browser are you using? Can you try other than what you are trying on?
Use the Network tab in IE developer tools or Firefox to see if you find something there..
Can you have the page up somewhere I can see?
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
if you go here:

http://alctracker-dev.creighton.edu/Default.aspx?AccessLevel=student

and use student and custud123 for the username and password you can see the page

also i got the same results in IE.
0
guru_samiCommented:
I am unable to open the link. I wonder if it's accessible outside your network.
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
i forgot about that part. i'm sorry.
0
guru_samiCommented:
- Did explicitly calling UpdatePanel Update() in button click make any difference?
- What does your Page that contains the usercontrol look like?
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
Unfortunately calling the Update, explicitly didn't make a difference. here is my page that contains my user control (see code below). my user control is:

<sttc:StudentsSignedInGrid ID="MainGrid" runat="server" ResultType="1" ucAccessLevel='<%# Eval("Page.AccessLevel") %>' />

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/site.master" CodeFile="Default.aspx.cs"
    Inherits="_Default" %>

<%@ Register Src="~/UserControls/StudentsSignedInGrid.ascx" TagName="StudentsSignedInGrid"
    TagPrefix="sttc" %>
<%@ Register Src="~/UserControls/ListOfStudentsGrid.ascx" TagName="StudentsListGrid"
    TagPrefix="sttc" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
    <script src="http://cod.jquery.com/jquery-1.9.1.js"></script>
    <%--<script type="text/javascript" src="Scripts/jQueryPrint.js"></script>--%>
    <script type="text/javascript">
        (function ($) {
            $.print = function (message, insertType) {
                insertType = insertType || "append";
                if (typeof (message) == "object") {
                    var string = "{<br>",
                    values = [],
                    counter = 0;
                    $.each(message, function (key, value) {
                        if (value && value.nodeName) {
                            var domnode = "&lt;" + value.nodeName.toLowerCase();
                            domnode += value.className ? " class='" + value.className + "'" : "";
                            domnode += value.id ? " id='" + value.id + "'" : "";
                            domnode += "&gt;";
                            value = domnode;
                        }
                        values[counter++] = key + ": " + value;
                    });
                    string += values.join(",<br>");
                    string += "<br>}";
                    message = string;
                }

                var $output = $("#print-output");

                if (!$output.length) {
                    $output = $("<div id='print-output' />").appendTo("body");
                }

                var newMsg = $('<div />', {
                    "class": "print-output-line",
                    html: message
                });

                $output[insertType](newMsg);
            };
        })(jQuery);

        $(document).ready(function () {
            var updateWait = setTimeout(fadeUpdate, 3000);
            function fadeUpdate() {
                $("div.UpdatedMessage").fadeOut(1000);
            }

            $("a.How").hover(function () {
                var myo = $(this).offset();
                $("div.HowTo").css({ left: (myo.left - 430) + "px", top: myo.top + -40 + "px" }).show();
            }, function () {
                $("div.HowTo").hide();
            });

            $("a.SnapShot").hover(function () {
                var myo = $(this).offset();
                $("div.SnapShot").css({ left: (myo.left + 150) + "px", top: myo.top + -40 + "px" }).show();
            }, function () {
                $("div.SnapShot").hide();
            });

            //                        $(".studentIdInput").keyup(function () {
            //                            var value = jQuery(this).val();
            //                            var rSt = '';
            //                            var lSt = '';
            //                            if (value.length == 17) {
            //                                rSt = value.substring(8);
            //                                lSt = rSt.slice(0, -2);
            //                                $(".studentIdInput").val(lSt);
            //                            }
            //                        });

            /*CREIGHTON*/
            $(".studentIdInput").keyup(function () {
                var value = jQuery(this).val();
                var rSt = '';
                var lSt = '';
                if (value.length == 100) {
                    rSt = value.substring(8);
                    lSt = rSt.slice(0, -2);
                    $(".studentIdInput").val(lSt);
                }
            });

            //            $(".studentIdInput").keypress(function (e) {
            //                    e.preventDefault();
            //            });

            //            $("#txtStudentIdSearchBox").keyup(function () {
            //                var myVal = jQuery(this).val();
            //                var myLen = jQuery(this).val().length;  //OR jQuery(this).size(); jQuery(this).length OR ;
            //                var rSt = '';
            //                var lSt = '';
            //                {
            //                    rSt = value.substring(8, Min(8, myLen));
            //                    lSt = rSt.slice(0, -2);
            //                    $(".studentIdInput").val(lSt);
            //                }
            //            }); 

            //            var timerid = 0;
            //            var counter = 0;
            //            var maxTime = 5;
            //            var correctAnswer = "this is a test";

            //            //$('#TexBox1').on('keydown', function (e) {
            //            $(".txtTestTimerValue").keydown(function (e) {
            //                if (e.keyCode !== 13 && e.keyCode !== 9) {
            //                    // start the timer if it's not running
            //                    if (timerid <= 0) {
            //                        timerid = setInterval(function () {
            //                            counter++;
            //                            $('#pcount').text('count: ' + counter + '/' + maxTime);
            //                            if (counter >= maxTime) {
            //                                clearInterval(timerid);
            //                                timerid = 0;
            //                                counter = 0;
            //                                $('#pcount').text('you took too long or did not enter a student i.d.');
            //                            }
            //                        }, 1000);
            //                    }

            //                }
            //                //console.log(e);
            //                else {
            //                    if ($('#TextBox1').val() === correctAnswer) {
            //                        clearInterval(timerid);
            //                        timerid = 0;
            //                        counter = 0;
            //                        $('#pcount').text('you got it!');
            //                    }
            //                }
            //            });
            //        });

            //        function starttimer() {
            //            count += 1;
            //            var oElem = document.getElementById("TextBox1");
            //            oElem.style.color = oElem.style.color == "red" ? "blue" : "red";
            //            document.getElementById("pcount").innerHTML = "Your Time Starts: " + count;
            //        }
            //        function stoptimer() {
            //            clearInterval(chkfn);
            //            chkfn = null;
            //            //count = 0;
            //            //document.getElementById("pcount").innerHTML = '';
            //}

            //        var count = 0, chkfn = null;

            /*CREIGHTON*/
            //        $(function () {
            //            $(".studentIdInput").keydown(function (e) {
            //                if (e.keyCode != 13) {
            //                    /*e.preventDefault();*/
            //                    chkfn = setInterval(starttimer, 1000)
            //                }
            //                else {
            //                    stoptimer();
            //                }
            //            });
            //        });
            //            var timerid = 0;
            //            var counter = 0;
            //            var maxTime = 5;
            //            var correctAnswer = "this is a test";
            //            var oElem = document.getElementById('divtxt');

            //            $(".studentIdInput").keypress(function (e) {
            //                if (e.keyCode !== 13 && e.keyCode !== 9) {
            //                    // start the timer if it's not running
            //                    if (timerid <= 0) {
            //                        timerid = setInterval(function () {
            //                            counter++;
            //                            oElem.style.color = oElem.style.color == "red" ? "blue" : "red";
            //                            document.getElementById('pcount').innerHTML = "Your Time Starts: " + count;
            //                            if (counter >= maxTime) {
            //                                clearInterval(timerid);
            //                                timerid = 0;
            //                                counter = 0;
            //                                $('pcount').text('you took too long');
            //                            }
            //                        }, 1000);
            //                    }

            //                }
            //                //console.log(e);
            //                else {
            //                    if ($('pcount').val() === correctAnswer) {
            //                        clearInterval(timerid);
            //                        timerid = 0;
            //                        counter = 0;
            //                        $('pcount').text('you got it!');
            //                    }
            //                }
            //            });

            var count = 0, chkfn = null;

            function changeColor() {
                // Call function with 1000 milliseconds gap
                chkfn = setInterval(starttimer(), 1000);
            }

            function starttimer() {
                count += 1;
                var oElem = document.getElementById('divtxt');
                oElem.style.color = oElem.style.color == "red" ? "blue" : "red";
                document.getElementById('pcount').innerHTML = "Your Time Starts: " + count;
            }

            $(function () {
                $(".testButtonClass").click(function (e) {
                    changeColor();
                    var oElem = $(document.getElementById('TextBox1'));
                    var oElemPara = $(document.getElementById('pcount'));
                    //changeColor();
                    //if (e.keyCode != 13) {
                    //e.preventDefault();
                    //$(".txtTestTimerValue").append("test");                      
                    //oElemPara.innerHTML = "Your Time Starts: " + count;
                    //$('#<%=TextBox1.ClientID%>').val("test");

                    //}
                    //else {
                    //e.preventDefault();
                    //}
                });
            });
        });
    </script>
    <%--    <script type="text/javascript">
        function ShowCurrentTime() {
            $.ajax({
                type: "POST",
                url: "Default.aspx/SnapShotCurrentWeekTotal",
                data: '{name: "' + $("#<%=lblAthleteUid.ClientID%>")[0].value + '" }',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnSuccess,
                failure: function (response) {
                    alert(response.d);
                }
            });
        }
    </script>--%>
    <style type="text/css">
        fieldset
        {
            margin-bottom: 1em;
        }
        input
        {
            display: block;
            margin-bottom: .25em;
        }
        #print-output, .print-output-line
        {
            width: 500px;
        }
        .print-output-line
        {
            white-space: pre;
            padding: 5px;
            font-family: monaco, monospace;
            font-size: .7em;
        }
        .studentIdInput, .prompt, .studentIdInput1, .ldapPswrd
        {
            float: left;
        }
        .studentIdInput, .studentIdInput1, .ldapPswrd
        {
            margin: 0px 9px 0 5px;
        }
        .studentFullName
        {
            float: left;
            padding: 13px 0 0 95px;
        }
        .rdBtnsAndSearch
        {
            width: 525px;
            margin: 11px 0 0 0;
        }
        .rdBtnsAndSearch, .srchContainer, .pnlButton
        {
            float: left;
        }
        .pnlButton
        {
            margin: 2px 0 0 0;
        }
        .srchContainer
        {
            width: 500px;
        }
        .notesProgram, .programAttended
        {
            margin: 10px 0 0 0;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:HiddenField runat="server" ID="hfAccessLevel" Value='<%# Eval("Page.AccessLevel") %>' />
    <div id="MainContainer">
        <div class="MainContent">
            <div class="TableContainer">
                <div class="FiltersContainer clearfix">
                    <div class="Filters clearfix" runat="server" id="div4">
                        <div class="srchContainer">
                            <div style="float: left; width: 700px;">
                                <fieldset>
                                    <div class="divTest" id="divTest" style="float: left;">
                                        <div style="float: left">
                                            <div id="divtxt">
                                                <p id="pcount" style="font: bold 24px verdana">
                                                </p>
                                            </div>
                                        </div>
                                        <div style="float: left">
                                            <asp:TextBox ID="TextBox1" type="text" class="txtTestTimerValue" runat="server" AutoPostBack="false"
                                                Width="73px" Style="margin: 0 96px 0 0;" />
                                            <asp:Button ID="testButton" CssClass="testButtonClass" runat="server" AutoPostBack="false" />
                                        </div>
                                        <%--<input id="btnStartTimer" class="btnStartTimer" />
                                           <input id="btnEndTimer" class="btnEndTimer" onclick="start/>--%>
                                    </div>
                                    <strong>Enter/Swipe Student ID:</strong><strong style="margin: 0 0 0 14px;">Enter password:</strong>
                                    <div id="Div2" class="rdBtnsAndSearch" runat="server" style="clear: none; width: 560px;">
                                        <ul style="background: none;">
                                            <li>
                                                <asp:RadioButton ID="rbtnStudentID" runat="server" AutoPostBack="false" Checked="false"
                                                    GroupName="AddEdit" CssClass="Radio" Text="Student ID" Visible="false" /></li>
                                        </ul>
                                        <asp:TextBox ID="txtStudentIdSearchBox" type="text" class="studentIdInput" runat="server"
                                            AutoPostBack="false" Width="73px" Style="margin: 0 96px 0 0;" />
                                        <%--<input id="Text1" type="text" class="studentIdInput"/>--%>
                                        <asp:TextBox ID="txtBxLDAPPswrd" type="text" runat="server" TextMode="Password" class="ldapPswrd"
                                            Font-Bold="true" ForeColor="GrayText" />
                                        <%--<asp:Literal ID="ltLDAPPswrd" runat="server" Text="Password"></asp:Literal>--%>
                                        <asp:Panel ID="pnlButton" CssClass="pnlButton" runat="server">
                                            <asp:LinkButton ID="lnkbtnFindStudent" runat="server" Text="Sign In / Out" CssClass="button small green"
                                                OnClick="lnkbtnFindStudent_Click"></asp:LinkButton>
                                            <asp:LinkButton ID="lnkbtnFindStudentStudent" runat="server" Text="Sign In / Out"
                                                CssClass="button small green" OnClick="lnkbtnFindStudentStudent_Click"></asp:LinkButton>
                                            <asp:LinkButton ID="LinkButton2" runat="server" Text="REFRESH" CssClass="button small green"
                                                OnClick="LinkButton2_Click"></asp:LinkButton>
                                        </asp:Panel>
                                        <asp:Panel ID="pnlAdjustReqHrs" CssClass="pnlButton" runat="server" Visible="false">
                                            <asp:Button ID="btnAdjustReqHrs" runat="server" Text="Adjust Required Hours" CssClass="button small green"
                                                OnClick="btnAdjustReqHrs_Click"></asp:Button>
                                        </asp:Panel>
                                    </div>
                                    <div class="updateAlert">
                                        <asp:Panel runat="server" ID="pnlUpdateConfirmation" Visible="false" CssClass="UpdatedMessage Alert SavedSmall">
                                            <h3>
                                                <asp:Label runat="server" ID="lblConfirmationMsg" Text="Required hours updated."></asp:Label></h3>
                                        </asp:Panel>
                                        <asp:Panel runat="server" ID="pnlAllSignedOut" Visible="false" CssClass="UpdatedMessage Alert SavedSmall">
                                            <h3>
                                                <asp:Label runat="server" ID="lblAllSignedOut" Text="All students were signed out."></asp:Label></h3>
                                        </asp:Panel>
                                        <asp:Panel runat="server" ID="pnlStudyHallHoursMsg" Visible="false" CssClass="UpdatedMessage Alert SavedSmall">
                                            <h3>
                                                <asp:Label runat="server" ID="lblStudyHallHoursMsg" Text="Study hall hours are between 9AM - 9PM Mon-Thur 9AM - 4PM Fri and 6PM - 9PM Sun."></asp:Label></h3>
                                        </asp:Panel>
                                        <asp:Panel runat="server" ID="pnlSignedOutAllStudents" Visible="false" CssClass="UpdatedMessage Alert SavedSmall">
                                            <h3>
                                                <asp:Label runat="server" ID="lblSignedOutAllStudents" Text="Signed out all remaining signed in students."></asp:Label></h3>
                                        </asp:Panel>
                                        <asp:Panel runat="server" ID="pnlInvalidIp" Visible="false" CssClass="UpdatedMessage Alert SavedSmall">
                                            <h3>
                                                <asp:Label runat="server" ID="Label1" Text="This computer has not been designated for study hall."></asp:Label></h3>
                                        </asp:Panel>
                                    </div>
                                    <script type="text/javascript" src="http://api.jquery.com/scripts/events.js"></script>
                                    <%--<script type="text/javascript">
                                        var xTriggered = 0;
                                        var myLength = 0;
                                        var myString;
                                        var value;
                                        $("#txtStudentIdSearchBox").keyup(function (event) {
                                            myLength = $(this).val().length;
                                            if (myLength == 17) {
                                                value = $("#txtStudentIdSearchBox").val();
                                                value = value.substring(8);
                                                value = value.substring(0, value.length - 2);
                                                $("#txtStudentIdSearchBox").val(value);
                                            }
                                            if (event.which == 13) {
                                                event.preventDefault();
                                            }

                                            xTriggered++;
                                            var msg = "Handler for .keypress() called " + xTriggered + " time(s).";

                                            $.print(msg, "html");
                                            $.print(event);
                                        });

                                        $("#other").click(function () {
                                            $("#target").keypress();
                                        });
                                    </script>--%>
                                </fieldset>
                            </div>
                            <div style="float: left;">
                                <div class="filterControls" style="float: left; width: 340px;">
                                    <asp:Panel ID="pnlHow" runat="server">
                                        <div class="Contain" style="width: 185px;">
                                            <a id="aHow" runat="server" class="How">How does this page work?</a></div>
                                        <div class="HowTo" style="display: none;">
                                            <div class="InfoContainer">
                                                <div class="InfoContent">
                                                    <div id="div5" runat="server">
                                                        <h6 id="h1" runat="server">
                                                            View signed in students. Sign students in and out.</h6>
                                                        <p id="p1" runat="server">
                                                            Here you can see all the signed in student athletes, as well as sign them in and
                                                            out. Signing in and out can be done by:
                                                            <ol style="list-style: decimal">
                                                                <li>Entering a complete student ID</li>
                                                                <li>Clicking the 'Select' button for the student in the list of students returned from
                                                                    doin a look up.</li>
                                                                <li><span>*</span>By doing a partial look up and then grabbing (copying and pasting)
                                                                    the desired student's ID into the 'Sign In / Out' box.</li>
                                                            </ol>
                                                            <br />
                                                            <br />
                                                            **If a partial look up is needed, a student can be looked up by partial first name,
                                                            last name or even partial student athlete ID. A list of matches will be returned
                                                            from which the desired student can be chosen and signed in.
                                                        </p>
                                                        <p id="p2" runat="server">
                                                            * Method typically used for finding student athletes that need to be signed in when
                                                            student ID is not available.<br />
                                                            ** May only be available for administrators of the system.
                                                        </p>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </asp:Panel>
                                    <asp:Label ID="lblIPAddy" runat="server" Text="students signed in"></asp:Label>
                                </div>
                            </div>
                        </div>
                        <div class="lstNameLookUp">
                            <asp:Panel runat="server" ID="pnlAdminFilter" Visible="false">
                                <fieldset>
                                    <strong>Look up student by: </strong>
                                    <div id="Div1" class="rdBtnsAndSearch" runat="server" style="clear: none">
                                        <ul class="Three">
                                            <li>
                                                <asp:RadioButton ID="rbtnFirstName" runat="server" AutoPostBack="false" Checked="false"
                                                    GroupName="AddEdit" CssClass="Radio" Text="Student First" /></li>
                                            <li>
                                                <asp:RadioButton ID="rbtnLastName" runat="server" GroupName="AddEdit" CssClass="Radio"
                                                    Text="Student Last Name" Checked="false" AutoPostBack="false" /></li>
                                            <li>
                                                <asp:RadioButton ID="rbtnFullName" runat="server" GroupName="AddEdit" CssClass="Radio"
                                                    Text="Student Full Name" Checked="false" /></li>
                                        </ul>
                                        <asp:TextBox ID="tbxLookupName" type="text" class="studentIdInput1" runat="server" />
                                        <asp:Panel ID="pnlLookUpButton" CssClass="pnlButton" runat="server">
                                            <asp:LinkButton ID="lbtnLookUp" runat="server" Text="Look Up Student" CssClass="button small green"
                                                OnClick="lnkbtnFindStudent_Click"></asp:LinkButton>
                                        </asp:Panel>
                                    </div>
                                </fieldset>
                            </asp:Panel>
                        </div>
                        <strong>
                            <asp:Label runat="server" ID="lblCurrentWeek"></asp:Label></strong>
                    </div>
                </div>
            </div>
            <div>
                <sttc:StudentsSignedInGrid ID="MainGrid" runat="server" ResultType="1" ucAccessLevel='<%# Eval("Page.AccessLevel") %>' />
            </div>
            <div>
                <sttc:StudentsListGrid ID="StudentListGrid" runat="server" ResultType="1" ucAccessLevel='<%# Eval("Page.AccessLevel") %>' />
            </div>
            <asp:Panel runat="server" ID="pnlSignInOut">
                <div class="AddrdssBookContent UserProfile clearfix">
                    <div id="divDeleteConfirmation" runat="server" align="center" class="confirmDelete"
                        style="display: none">
                        <div class="clearfix">
                            <div class="inner">
                                <h4>
                                    <asp:Label runat="server" ID="lblPasswordPrompt" Text=""></asp:Label></h4>
                                <asp:Label runat="server" ID="lblMonitorPassword" Text=""></asp:Label>
                                <asp:CheckBox runat="server" ID="cbxSignOutAll" Text="Sign Out All" />
                                <asp:TextBox ID="tbxMonitorPswrd" runat="server" TextMode="Password"></asp:TextBox>
                                <div class="notesProgram">
                                    <div class="signInOutNotes">
                                        <h4>
                                            <asp:Label runat="server" ID="lblNotes" Text="Notes: "></asp:Label></h4>
                                        <asp:TextBox ID="tbxNotes" runat="server" TextMode="MultiLine" Rows="3" Width="300"></asp:TextBox>
                                    </div>
                                    <div class="programAttended">
                                        <h4>
                                            <asp:Label runat="server" ID="lblPrgrmAttnd" Text="Program Attended: "></asp:Label></h4>
                                        <asp:TextBox ID="tbxPrgrmAttnd" runat="server" TextMode="MultiLine" Rows="3" Width="300"></asp:TextBox>
                                    </div>
                                </div>
                                <div class="Buttons">
                                    <ul style="display: none;">
                                        <li>
                                            <asp:RadioButton ID="rbtnLockPassword" runat="server" AutoPostBack="false" Checked="false"
                                                GroupName="LockUnlockPassword" CssClass="Radio" Text="Lock password" /></li>
                                        <li>
                                            <asp:RadioButton ID="rbtnUnlockPassword" runat="server" GroupName="LockUnlockPassword"
                                                CssClass="Radio" Text="Unlock password" Checked="false" /></li>
                                    </ul>
                                    <asp:Button ID="btnSignIn" CssClass="button small" runat="server" Text="Sign In / Out"
                                        OnClick="btnSignIn_click" Style="margin-left: 15px;" />
                                    <asp:Button ID="btnCancel" CssClass="button small" runat="server" Text="Cancel" />
                                </div>
                                <asp:Label runat="server" ID="lblInvalidPassword" Visible="false"></asp:Label>
                            </div>
                        </div>
                    </div>
                </div>
            </asp:Panel>
            <asp:Panel runat="server" ID="Panel1">
                <div class="AddrdssBookContent UserProfile clearfix">
                    <div id="divWeekTimeTotal" runat="server" align="center" class="confirmDelete" style="display: none">
                        <div class="clearfix">
                            <div class="inner">
                                <div class="notesProgram">
                                    <div class="signInOutNotes">
                                        <h4>
                                            <asp:Label runat="server" ID="lblCurrentWeekTotal" Text="Current Week Stats"></asp:Label></h4>
                                        <asp:TextBox ID="txbCurrentWeekTotal" runat="server" TextMode="MultiLine" Rows="5"
                                            Width="300" Font-Size="Large" Font-Bold="true"></asp:TextBox>
                                        <asp:LinkButton ID="LinkButton1" CssClass="button small" runat="server" Text="Close"
                                            Visible="false" />
                                        <act:ModalPopupExtender ID="deleteModalPopupExtender1" runat="server" CancelControlID="btnCancel"
                                            OkControlID="btnDelete" TargetControlID="LinkButton1" PopupControlID="divWeekTimeTotal"
                                            BackgroundCssClass="modalBackground" />
                                        <act:ConfirmButtonExtender ID="deleteConfirmButtonExtender1" runat="server" TargetControlID="LinkButton1"
                                            Enabled="True" DisplayModalPopupID="deleteModalPopupExtender1" />
                                    </div>
                                </div>
                                <div class="Buttons">
                                    <asp:LinkButton ID="lnkbtnClose" CssClass="button small" runat="server" Text="Close"
                                        OnClick="lnkbtnClose_OnClick" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </asp:Panel>
        </div>
    </div>
</asp:Content>

Open in new window

0
guru_samiCommented:
I'll have to see it tomorrow.
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
ok. thanks for your help tonight.
0
guru_samiCommented:
Honestly I am really not sure what's wrong. I see a lots of javascript on the page and wondering if something is interfering after the first Refresh.
If you drop your user control on the test page you tried earlier, does that work. Just checking if it's the UserControl the problem or the page.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Michael SterlingWeb Applications DeveloperAuthor Commented:
i will try that. i was thinking something similar. i was going to try and strip down the page to as little code / script as possible to see what the problem could be.
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
i dropped the control onto a blank page and the update worked. so i will now incrementally add pieces of the original page it was on until it breaks again, and then I shall know what the problem is / was. thanks for your help.
0
Michael SterlingWeb Applications DeveloperAuthor Commented:
I found the C# code that seems to be causing the problem. it appears to be a combination of something going on in the C# code and a couple panels in my site.master page and a panel in my default.aspx page. below is the code from my site.master page, my default.aspx page, and the code behind my default.aspx page that is causing the problem. I just discovered that this was the code/html causing the problem, because as I indicated above, I started from scratch, with a blank aspx page that is a child page of my site.master page and incrementally added C# code and HTML until I broke the refresh button on my user control, which is embedded in my default.aspx page. at this point, I still don't know WHY its breaking, but I know, roughly, what is breaking it.

my site.master page
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="site.master.cs" Inherits="site" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    </asp:ContentPlaceHolder>
    <link href="~/css/StudentList.css" rel="Stylesheet" type="text/css" />
    <link href="~/css/site.css" rel="Stylesheet" type="text/css" />
    <link href="~/css/master.css" rel="Stylesheet" type="text/css" />
    <link href="~/css/content.css" rel="Stylesheet" type="text/css" />
    <link href="~/css/ProviderContent.css" rel="Stylesheet" type="text/css" />
    <link href="~/css/ConsumerHome.css" rel="Stylesheet" type="text/css" />
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
    <script type="text/javascript" src="../js/common.js"></script>
    <script type="text/javascript" src="../js/jquery-ui-1.8.11.custom.min.js"></script>
    <script type="text/javascript">

        var delay = (function () {
            var timer = 0;
            return function (callback, ms) {
                clearTimeout(timer);
                timer = setTimeout(callback, ms);
            };
        })();

        $(document).ready(function () {
            $("a.ViewDetails").toggle(function () {
                $(".ShipmentDetailsFull").show();
                $(".BillingDetails").show();
                $(this).text("hide complete details");
            }, function () {
                $(".ShipmentDetailsFull").hide();
                $(".BillingDetails").hide();
                $(this).text("view complete details");

            });



            $("#searchBox").keyup(function (event) {
                var cur = this.value;
                delay(function () {
                    lookUp(cur, event.which);
                }, 250);
            });
            $("#moreLink").hover(function () {
                $(this).addClass("moreLinkAt");
                $("#moreList").show();
                $("#results").hide();
                $(".search").removeClass("searching");
                var element = $("#moreLink");
                var offset = element.offset();
                $("#moreList").css({ "left": offset.left - 135, "top": offset.top + 70 });
            },
            function () {
                $("#moreList").hide();
                $(this).removeClass("moreLinkAt");
            }
                    );
            $("#moreList").hover(
              function () {
                  $("#moreLink").addClass("moreLinkAt");
                  $("#moreList").show();

              },
              function () {
                  $("#moreLink").removeClass("moreLinkAt");
                  $("#moreList").hide();
              }
            );

            $('#searchBox').blur(function () {
                if ($(this).val() == "") {
                    $(this).val("Shipment, company or #");
                    $(this).addClass("wmark");
                }
            });

            $('#searchBox').hover(function () {
                if (($(this).val() != "") && ($(this).val() != "Shipment, company or #")) {
                    $(".search").addClass("searching");
                    $("#results").show();
                }
            });

            $('#searchBox').focus(function () {
                if ($(this).val() == "Shipment, company or #") {
                    $(this).val("");
                    $(this).removeClass('wmark');
                }
                $("#results").show();
                $(".search").addClass("searching");

            });
            $('#results').mouseleave(function () {
                $(this).hide();
                $(".search").removeClass("searching");
            });

        });
    </script>
    <style type="text/css">
        .dl-site-area
        {
            margin: 32px 0 0 0;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server" autocomplete="off">
    <%--<asp:ScriptManager ID="scrptMngr" runat="server"></asp:ScriptManager>--%>
    <act:ToolkitScriptManager ID="ScriptManagerContent1" runat="server" EnablePartialRendering="true"
        LoadScriptsBeforeUI="true" ScriptMode="Release" />
    <div class="mstrHdr">
        <div class="mstrHdrImg">
            <%--/*QUINNIPIAC*/--%>
            <%--<img id="Img1" src="images/QUbobcat_01.png" alt="QU Bobcat" runat="server" />--%>
            <%--/*ST. JOSEPHS*/--%>
            <%--<img id="Img1" src="images/SJUHawk.jpg" alt="QU Bobcat" runat="server" />--%>
            <%--/*CREIGHTON*/--%>
            <img id="Img1" src="images/CUJays.png" alt="Creighton Jays" runat="server" />
        </div>
        <asp:ContentPlaceHolder ID="LoginContent" runat="server">
            <asp:Panel ID="pnlSiteArea" CssClass="dl-site-area" runat="server">
                <div id="nav">
                    <div id="content">
                        <ul id="mainNav">
                        </ul>
                        <div id="AccountNav" runat="server" class="AccountNav">
                            <a href="#" id="moreLink">
                                <img src="/images/gear.png" alt="settings" /></a>
                            <ul id="moreList" style="display: none;">
                                <asp:Panel ID="pnlAdminLinks" CssClass="dl-Admin-Links" runat="server">
                                    <li class="main" runat="server" id="liDefault">
                                        <asp:HyperLink ID="hplDefault" CssClass="MyNetwork" runat="server" NavigateUrl="~/Default.aspx?AccessLevel=QUSuperMan"><strong>Sign In Page</strong></asp:HyperLink>
                                    </li>
                                    <li class="main" runat="server" id="liMyNetwork">
                                        <asp:HyperLink ID="hplEditStudentTime" CssClass="MyNetwork" runat="server" NavigateUrl="~/StudentTime.aspx?AccessLevel=QUSuperMan"><strong>Add / Edit Time</strong></asp:HyperLink>
                                    </li>
                                    <li class="main" runat="server" id="liEditStudentInfo">
                                        <asp:HyperLink ID="hplEditStudentInfo" CssClass="MyNetwork" runat="server" NavigateUrl="~/AddEditStudent.aspx?AccessLevel=QUSuperMan"><strong>Add / Edit Student Info</strong></asp:HyperLink>
                                    </li>
                                    <li class="main" runat="server" id="liUsers">
                                        <asp:HyperLink ID="hplUsers" CssClass="MyNetwork" runat="server" NavigateUrl="~/CreatingUserAccounts.aspx?AccessLevel=QUSuperMan"><strong>Add Users</strong></asp:HyperLink>
                                    </li>
                                    <li class="main" runat="server" id="li3">
                                        <asp:HyperLink ID="HyperLink3" CssClass="MyNetwork" runat="server" NavigateUrl="~/UsersAndRoles.aspx?AccessLevel=QUSuperMan"><strong>Manage User Roles</strong></asp:HyperLink>
                                    </li>
                                    <li class="main" runat="server" id="li1">
                                        <asp:HyperLink ID="HyperLink1" CssClass="MyNetwork" runat="server" NavigateUrl="~/WeeklyLogRptAll.aspx?AccessLevel=QUSuperMan"><strong>Weekly Log Report</strong></asp:HyperLink>
                                    </li>
                                    <li class="main" runat="server" id="li5">
                                        <asp:HyperLink ID="HyperLink4" CssClass="MyNetwork" runat="server" NavigateUrl="~/WeeklyLogHistoricReport.aspx?AccessLevel=QUSuperMan"><strong>Weekly Log Report Historic</strong></asp:HyperLink>
                                    </li>
                                    <li class="main" runat="server" id="liReports">
                                        <asp:HyperLink ID="hplReports" CssClass="MyNetwork" runat="server" NavigateUrl="~/SemesterTotalsReport.aspx?AccessLevel=QUSuperMan"><strong>Semester Totals Report</strong></asp:HyperLink>
                                    </li>
                                    <li class="main" runat="server" id="li4">
                                        <asp:HyperLink ID="HyperLink2" CssClass="MyNetwork" runat="server" NavigateUrl="~/SemesterTotalsReportIndividual.aspx?AccessLevel=QUSuperMan"><strong>Semester Totals Report Individual</strong></asp:HyperLink>
                                    </li>
                                    <li class="main" runat="server" id="li2">
                                        <asp:HyperLink ID="hplnkLoadStudents" CssClass="MyNetwork" runat="server" NavigateUrl="~/CULoadStudents.aspx?AccessLevel=QUSuperMan"><strong>Load Students</strong></asp:HyperLink>
                                    </li>
                                </asp:Panel>
                                <li class="Last">
                                    <asp:LinkButton runat="server" ID="cmdLogMeOut" Text="Sign out" OnClick="HandleLogOut"></asp:LinkButton></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </asp:Panel>
            <asp:HiddenField runat="server" ID="hfAccessLevel" Value="" />
        </asp:ContentPlaceHolder>
    </div>
    <div>
        <asp:ContentPlaceHolder ID="MainContent" runat="server">
            <asp:Menu ID="menuAdmin" runat="server" CssSelectorClass="sf-menu sf-navbar" DataSourceID="smdsAdminMenu"
                Orientation="Horizontal" />
            <asp:SiteMapDataSource ID="smdsAdminMenu" runat="server" SiteMapProvider="AdminSiteMapProvider"
                ShowStartingNode="false" />
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

Open in new window


my child aspx page
<%@ Page Title="" Language="C#" MasterPageFile="~/site.master" AutoEventWireup="true"
    CodeFile="AlternateSignedInListPage.aspx.cs" Inherits="AlternateSignedInListPage" %>

<%@ Register Src="~/UserControls/StudentsSignedInGrid.ascx" TagName="StudentsSignedInGrid" TagPrefix="sttc" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://cod.jquery.com/jquery-1.9.1.js"></script>
    <script type="text/javascript">
        (function ($) {
            $.print = function (message, insertType) {
                insertType = insertType || "append";
                if (typeof (message) == "object") {
                    var string = "{<br>",
                    values = [],
                    counter = 0;
                    $.each(message, function (key, value) {
                        if (value && value.nodeName) {
                            var domnode = "&lt;" + value.nodeName.toLowerCase();
                            domnode += value.className ? " class='" + value.className + "'" : "";
                            domnode += value.id ? " id='" + value.id + "'" : "";
                            domnode += "&gt;";
                            value = domnode;
                        }
                        values[counter++] = key + ": " + value;
                    });
                    string += values.join(",<br>");
                    string += "<br>}";
                    message = string;
                }

                var $output = $("#print-output");

                if (!$output.length) {
                    $output = $("<div id='print-output' />").appendTo("body");
                }

                var newMsg = $('<div />', {
                    "class": "print-output-line",
                    html: message
                });

                $output[insertType](newMsg);
            };
        })(jQuery);

        $(document).ready(function () {
            var updateWait = setTimeout(fadeUpdate, 3000);
            function fadeUpdate() {
                $("div.UpdatedMessage").fadeOut(1000);
            }

            $("a.How").hover(function () {
                var myo = $(this).offset();
                $("div.HowTo").css({ left: (myo.left - 430) + "px", top: myo.top + -40 + "px" }).show();
            }, function () {
                $("div.HowTo").hide();
            });

            $("a.SnapShot").hover(function () {
                var myo = $(this).offset();
                $("div.SnapShot").css({ left: (myo.left + 150) + "px", top: myo.top + -40 + "px" }).show();
            }, function () {
                $("div.SnapShot").hide();
            });

            /*CREIGHTON*/
            $(".studentIdInput").keyup(function () {
                var value = jQuery(this).val();
                var rSt = '';
                var lSt = '';
                if (value.length == 100) {
                    rSt = value.substring(8);
                    lSt = rSt.slice(0, -2);
                    $(".studentIdInput").val(lSt);
                }
            });

            /*CREIGHTON*/
            $(function () {
                $(".studentIdInput").keypress(function (e) {
                    if (e.keyCode == 13) {
                        e.preventDefault();
                    }
                });
            });
        });
    </script>
    <style type="text/css">
        fieldset
        {
            margin-bottom: 1em;
        }
        input
        {
            display: block;
            margin-bottom: .25em;
        }
        #print-output, .print-output-line
        {
            width: 500px;
        }
        .print-output-line
        {
            white-space: pre;
            padding: 5px;
            font-family: monaco, monospace;
            font-size: .7em;
        }
        .studentIdInput, .prompt, .studentIdInput1, .ldapPswrd
        {
            float: left;
        }
        .studentIdInput, .studentIdInput1, .ldapPswrd
        {
            margin: 0px 9px 0 5px;
        }
        .studentFullName
        {
            float: left;
            padding: 13px 0 0 95px;
        }
        .rdBtnsAndSearch
        {
            width: 525px;
            margin: 11px 0 0 0;
        }
        .rdBtnsAndSearch, .srchContainer, .pnlButton
        {
            float: left;
        }
        .pnlButton
        {
            margin: 2px 0 0 0;
        }
        .srchContainer
        {
            width: 500px;
        }
        .notesProgram, .programAttended
        {
            margin: 10px 0 0 0;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="LoginContent" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="Server">
    <div>
        <sttc:studentssignedingrid id="MainGrid" runat="server" resulttype="1" ucaccesslevel='<%# Eval("Page.AccessLevel") %>' />
    </div>
</asp:Content>

Open in new window


the code behind my child aspx page
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using StudyTimeTracker.Common.Domain;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using System.Collections.Specialized;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration;
using StudyTimeTracker.Enterprise.ExceptionHandling;
using System.Text;
using StudyTimeTracker.Common.Data;
using System.Web.Mail;
using System.Collections;
using System.IO;
using StudyTimeTracker.Enterprise.Data;
/*FOR CREIGHTON*/
using System.DirectoryServices;
using System.Security;
using System.Data.OracleClient;
using System.Runtime.InteropServices;

public partial class AlternateSignedInListPage : System.Web.UI.Page
{
    public String AccessLevel
    {
        get
        {
            return Request.QueryString["AccessLevel"];
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        ShowHidePanels();
    }

    private void ShowHidePanels()
    {
        ContentPlaceHolder cphMain;
        Panel pnlAdminFilter = null;
        cphMain = (ContentPlaceHolder)Master.FindControl("MainContent");

        ContentPlaceHolder cph;
        Panel pnl = null;
        Panel pnlAdminLinks = null;

        cph = (ContentPlaceHolder)Master.FindControl("LoginContent");

        if (cph != null)
        {
            pnl = (Panel)cph.FindControl("pnlSiteArea");
            pnlAdminLinks = (Panel)cph.FindControl("pnlAdminLinks");
        }

        if (pnlAdminLinks != null)
        {
            if (AccessLevel != "QUSuperMan")
                pnlAdminLinks.Visible = false;
            else
                pnlAdminLinks.Visible = true;
        }

        if (cphMain != null)
        {
            pnlAdminFilter = (Panel)cphMain.FindControl("pnlAdminFilter");

            if (AccessLevel == "QUSuperMan")
                pnlAdminFilter.Visible = true;
            else
                pnlAdminFilter.Visible = false;
        }

    }

    protected void lkbtnRefreshGrid_OnClick(object sender, EventArgs e)
    {
        //txbxTest.Text = DateTime.Now.ToString();
    }
}

Open in new window


my user control HTML
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="StudentsSignedInGrid.ascx.cs"
    Inherits="UserControls_StudentsSignedInGrid" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>
<asp:UpdatePanel runat="server" ID="upStudentLoginGrid" UpdateMode="Conditional">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="lkbtnRefreshGrid" EventName="Click" />
    </Triggers>
    <ContentTemplate>
        <div id="divLnkBtn" runat="server" style="float: left; clear: both; width: 100%">
            <asp:LinkButton runat="server" ID="lkbtnRefreshGrid" Text="Refresh" AutoPostBack="true"
                CssClass="button small green" OnClick="lkbtnRefreshGrid_OnClick" />
        </div>
        <div id="divGrdVw" runat="server" style="float: left;">
            <asp:GridView ID="gdvStudentsSignedIn" runat="server" AutoGenerateColumns="false"
                CssClass="SignedInGrid" GridLines="None" AllowSorting="true" AllowPaging="true"
                PageSize="500" PagerStyle-HorizontalAlign="Center" OnRowDataBound="gdvStudentsSignedIn_OnRowDatabound"
                OnSorting="gdvShipments_OnSorting" PageIndex="0" OnRowCommand="gdvStudentSignedIn_OnRowCommand"
                OnPageIndexChanging="gdvStudentsSignedIn_OnPageIndexChanging">
                <Columns>
                    <asp:TemplateField HeaderText="Record ID" SortExpression="1" Visible="false" ItemStyle-CssClass="StudentName">
                        <ItemTemplate>
                            <h2>
                                <asp:Label ID="lblRecordID" runat="server" CssClass="StudentNameLabel" Text='<%# Eval("InOutUid") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Student ID" SortExpression="1" ItemStyle-CssClass="StudentName"
                        HeaderStyle-Width="75px">
                        <ItemTemplate>
                            <h2>
                                <asp:Label ID="lblAthleteUid" runat="server" CssClass="StudentNameLabel" Text='<%# Eval("AthleteUiD") %>'></asp:Label></a><h2>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="StudentName" SortExpression="2" HeaderStyle-Width="200px">
                        <ItemTemplate>
                            <div id="lblStudentIDForSnapShot">
                                <h2>
                                    <asp:Label ID="lblStudentName" runat="server" Text='<%# Eval("AthleteName") %>'></asp:Label></h2>
                            </div>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Time In" SortExpression="3" HeaderStyle-Width="175px">
                        <ItemTemplate>
                            <h2>
                                <asp:Label ID="lblTimeIn" runat="server" Text='<%# Eval("TimeIn") %>'></asp:Label></h2>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Since Signed In" HeaderStyle-Width="100px" HeaderStyle-Font-Underline="true">
                        <ItemTemplate>
                            <h2>
                                <asp:Label runat="server" ID="lblSinceSignedIn" CssClass="sinceSignedIn" Text='<%# CalculateTime(Eval("TimeIn"), Eval("AthleteUid")) %>'></asp:Label></h2>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Team / Sport" SortExpression="5" HeaderStyle-Width="175px">
                        <ItemTemplate>
                            <h2>
                                <asp:Label ID="lblTeamName" runat="server" Text='<%# Eval("TeamName") %>'></asp:Label></h2>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-Width="100px">
                        <ItemTemplate>
                            <asp:LinkButton runat="server" ID="lknBtnWeeklyTotal" Text="Week Total" CommandName="FindCurrentWeekTotal"
                                CommandArgument='<%# Eval("AthleteUid") %>' CssClass="button small green" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:LinkButton runat="server" ID="btnSignOut" Text="Sign Out" CommandName="SignOut"
                                CommandArgument='<%# Eval("InOutUid") %>' CssClass="button small green" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <PagerSettings Mode="NextPrevious" />
                <PagerStyle CssClass="Paging" />
                <PagerTemplate>
                    <div class="Paging">
                        <asp:LinkButton ID="PreviousLinkButton" runat="server" CommandArgument="Prev" CommandName="Page"
                            CssClass="PagerControl" Text="Prev"></asp:LinkButton>
                        <asp:Label ID="PageDescriptionLabel" runat="server" CssClass="PagerControl"></asp:Label>
                        <asp:LinkButton ID="NextLinkButton" runat="server" CommandArgument="Next" CommandName="Page"
                            CssClass="PagerControl" Text="Next"></asp:LinkButton>
                    </div>
                </PagerTemplate>
            </asp:GridView>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>

Open in new window


the code behind my user control (what i think is important)
    protected void Page_Load(object sender, EventArgs e)
    {
        //if ( (!IsPostBack) || ( Refresh == "1"))
        if (!IsPostBack)
            BindData();
    }

    public void BindData()
    {
        StudentListBaseList studentList;

        studentList = StudentListProcessor.GetAllSignedInStudents("", SearchArgs);

        BindData(studentList);

    }

    private void BindData(StudentListBaseList studentList)
    {
        int pageSize = gdvStudentsSignedIn.PageSize;
        int currentPage = gdvStudentsSignedIn.PageIndex;
        int lastPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(studentList.Count / gdvStudentsSignedIn.PageSize)));
        int maxCount = ((currentPage + 1) * gdvStudentsSignedIn.PageSize);
        if (maxCount > studentList.Count) maxCount = studentList.Count;

        if (Session["StudentBaseListSortType"] != null)
            studentList = GetSortedStudentBaseList();

        gdvStudentsSignedIn.DataSource = studentList;
        gdvStudentsSignedIn.DataBind();

        if (studentList.Count > 0)
        {
            LinkButton prevLinkButton = (LinkButton)gdvStudentsSignedIn.BottomPagerRow.FindControl("PreviousLinkButton") as LinkButton;
            LinkButton nextLinkButton = (LinkButton)gdvStudentsSignedIn.BottomPagerRow.FindControl("NextLinkButton") as LinkButton;
            Label pageDescriptionLabel = (Label)gdvStudentsSignedIn.BottomPagerRow.FindControl("PageDescriptionLabel") as Label;
            prevLinkButton.Text = "< prev " + pageSize.ToString();
            nextLinkButton.Text = "next " + pageSize.ToString() + " >";


            prevLinkButton.Enabled = (currentPage > 0);
            nextLinkButton.Enabled = (currentPage < lastPage);
            pageDescriptionLabel.Text = String.Format("{0} to {1} of {2}", (currentPage * pageSize) + 1, maxCount, studentList.Count);
        }
    }

    protected void lkbtnRefreshGrid_OnClick(object sender, EventArgs e)
    {
        BindData();
        gdvStudentsSignedIn.DataBind();
        upStudentLoginGrid.Update();
    }

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.