Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7411505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:23:50+00:00 2026-05-29T06:23:50+00:00

Overview: I have two text boxes at the top of this form for inputting

  • 0

Overview:

I have two text boxes at the top of this form for inputting a beginning/ending date.
In the middle of the form I have a gridview that is populated with rows based on those dates.
At the bottom of the form I have a report generated based on which row is selected in the grid.

I selected the BeginningDate and the EndingDate and the gridview becomes populated (working). When I click the “Select” button on a row in the grid something is happening that makes it break. The row isn’t selected. I know this because the CSS thats usually applied (by default) to a selected row in the gridview is not applied.

Additionally in the code-behind I’m setting…

lblGridError.Text = gridJobsReport.SelectedIndex.ToString()

The page load even has the same code, so the label reads “-1” when the page loads but never changes when I click the select buttons on the gridview. Something is breaking my Async postbacks. I wish I understood viewstate better, I’m always suspicious of it being the culprit but honestly I have no idea.

<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="BidReport.aspx.vb" Inherits="BidReport" %>

<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server"> 
    </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server"> 
            <ajaxToolkit:ToolkitScriptManager ID="tsmgrJobsReport" runat="server" 
                CombineScripts="True">
            </ajaxToolkit:ToolkitScriptManager>
        <p>
            Enter a date range to populate the Jobs Grid.</p>
        <asp:UpdatePanel ID="uPanelForm" runat="server">
            <ContentTemplate>
                <table>
                    <tr>
                        <td style="text-align: right">
                            <asp:Label ID="lblBeginningDate" runat="server" Text="Beginning Date:"></asp:Label></td>
                        <td>
                            <asp:TextBox ID="txtBeginningDate" runat="server" AutoPostBack="True" 
                                CausesValidation="True"></asp:TextBox>
                            <ajaxToolkit:CalendarExtender ID="txtBeginningDate_CalendarExtender" 
                                runat="server" 
                                TargetControlID="txtBeginningDate">
                            </ajaxToolkit:CalendarExtender>
                        </td>
                        <td>
                            <asp:RequiredFieldValidator ID="rfvBeginningdate" runat="server" 
                                ControlToValidate="txtBeginningDate" 
                                ErrorMessage="You must enter the Beginning Date" Font-Bold="True" 
                                ForeColor="Red">*</asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="revBeginningDate" runat="server" 
                                ControlToValidate="txtBeginningDate" 
                                ErrorMessage="Posted Date must be in the format &quot;DD/MM/YYYY&quot;" 
                                Font-Bold="True" ForeColor="Red" 
                                ValidationExpression="^([1-9]|1[012])/([1-9]|[12][0-9]|3[01])/(20\d\d)$">*</asp:RegularExpressionValidator>
                        </td>
                        <td rowspan="2">
                            <asp:CompareValidator ID="cvBeginDateLTEndDate" runat="server" 
                                ControlToCompare="txtEndingDate" ControlToValidate="txtBeginningDate" 
                                ErrorMessage="Beginning Date must be earlier than the Ending Date." 
                                Font-Bold="True" ForeColor="Red" Operator="LessThan">*</asp:CompareValidator>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right">
                            <asp:Label ID="lblEndingDate" runat="server" Text="Ending Date:"></asp:Label></td>
                        <td>
                            <asp:TextBox ID="txtEndingDate" runat="server" AutoPostBack="True" 
                                CausesValidation="True"></asp:TextBox>

                            <ajaxToolkit:CalendarExtender ID="txtEndingDate_CalendarExtender" 
                                runat="server" TargetControlID="txtEndingDate">
                            </ajaxToolkit:CalendarExtender>
                        </td>
                        <td>
                            <asp:RequiredFieldValidator ID="rfvEndingDate" runat="server" 
                                ControlToValidate="txtEndingDate" 
                                ErrorMessage="You must enter the EndingDate Date" Font-Bold="True" 
                                ForeColor="Red">*</asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="revEndingDate" runat="server" 
                                ControlToValidate="txtEndingDate" 
                                ErrorMessage="Posted Date must be in the format &quot;DD/MM/YYYY&quot;" 
                                Font-Bold="True" ForeColor="Red" 
                                ValidationExpression="^([1-9]|1[012])/([1-9]|[12][0-9]|3[01])/(20\d\d)$">*</asp:RegularExpressionValidator>
                        </td>
                    </tr>
                </table>
        <asp:ValidationSummary ID="valsumDates" runat="server" ForeColor="Red" />

        <p>Click or Tap the &quot;SELECT&quot; button in the right column next to the Job you want and 
            a report will be generated below.</p>

                <asp:GridView ID="gridJobsReport" runat="server" AutoGenerateColumns="False" 
                            CellPadding="4" DataKeyNames="PostingID" DataSourceID="sqlDSReportGrid" 
                            ForeColor="#333333" GridLines="Horizontal" 
                            ShowHeaderWhenEmpty="True" Width="100%">
                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                            <Columns>
                                <asp:BoundField DataField="PostingID" HeaderText="PostingID" ReadOnly="True" 
                                    SortExpression="PostingID" >
                                    <ItemStyle HorizontalAlign="Center" />
                                    </asp:BoundField>

                                <asp:BoundField DataField="Department" HeaderText="Department" 
                                    SortExpression="Department" />

                                <asp:BoundField DataField="JobName" HeaderText="JobName" 
                                    SortExpression="JobName" />

                                <asp:BoundField DataField="Shift" HeaderText="Shift" SortExpression="Shift" >
                                    <ItemStyle HorizontalAlign="Center" />
                                    </asp:BoundField>

                                <asp:BoundField DataField="Needs" HeaderText="Needs" 
                                    SortExpression="Needs" >
                                    <ItemStyle HorizontalAlign="Center" />
                                    </asp:BoundField>

                                <asp:BoundField DataField="PostedDate" HeaderText="PostedDate" 
                                    SortExpression="PostedDate" DataFormatString="{0:d}" >
                                    <ItemStyle HorizontalAlign="Center" />
                                    </asp:BoundField>

                                <asp:BoundField DataField="PostedTime" HeaderText="Time" 
                                    SortExpression="PostedTime" DataFormatString="{0:t}" >
                                    <ItemStyle HorizontalAlign="Center" />
                                    </asp:BoundField>

                                <asp:BoundField DataField="ClosingDate" HeaderText="ClosingDate" 
                                    SortExpression="ClosingDate" DataFormatString="{0:d}" >
                                    <ItemStyle HorizontalAlign="Center" />
                                    </asp:BoundField>

                                <asp:BoundField DataField="ClosingTime" HeaderText="Time" 
                                    SortExpression="ClosingTime" DataFormatString="{0:t}" >
                                    <ItemStyle HorizontalAlign="Center" />
                                    </asp:BoundField>

                                <asp:CommandField ButtonType="Button" CausesValidation="True"
                                    ShowSelectButton="true" />
                            </Columns>
                            <EditRowStyle BackColor="#999999" />
                            <EmptyDataRowStyle HorizontalAlign="Center" />
                            <EmptyDataTemplate>
                                There is currently no data to display based on the date range provided.
                            </EmptyDataTemplate>
                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                            <SortedAscendingCellStyle BackColor="#E9E7E2" />
                            <SortedAscendingHeaderStyle BackColor="#506C8C" />
                            <SortedDescendingCellStyle BackColor="#FFFDF8" />
                            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                        </asp:GridView>
                        <br />
                    <asp:Label ID="lblGridError" runat="server"></asp:Label>
            </ContentTemplate>
        </asp:UpdatePanel>
            <ajaxToolkit:UpdatePanelAnimationExtender ID="uPanelForm_UpdatePanelAnimationExtender" 
                runat="server" TargetControlID="uPanelForm">
            </ajaxToolkit:UpdatePanelAnimationExtender>
        <p>You can print or save the report using the buttons at the top of the report.</p>
        <asp:UpdatePanel ID="uPanelJobsReport" runat="server">
            <ContentTemplate>
                <rsweb:ReportViewer ID="rvJobsReport" runat="server" Width="100%">
                    </rsweb:ReportViewer>

            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="gridJobsReport" 
                    EventName="SelectedIndexChanged" />
            </Triggers>
        </asp:UpdatePanel>

        <asp:SqlDataSource ID="sqlDSReportGrid" runat="server" 
                ConnectionString="<%$ ConnectionStrings:JobsDB %>" 
                SelectCommand="SELECT dbo.tblJobPostings.PostingID, dbo.tblDepartments.Department, dbo.tblJobs.JobName, 
                                    dbo.tblJobPostings.Shift, dbo.tblJobPostings.Needs, dbo.tblJobPostings.PostedDate, 
                                    dbo.tblJobPostings.PostedTime, dbo.tblJobPostings.ClosingDate, dbo.tblJobPostings.ClosingTime 
                                FROM dbo.tblJobPostings 
                                    INNER JOIN dbo.tblJobs ON dbo.tblJobPostings.JobID = dbo.tblJobs.JobID 
                                    INNER JOIN dbo.tblDepartments ON dbo.tblJobPostings.DeptID = dbo.tblDepartments.DeptID 
                                WHERE dbo.tblJobPostings.ClosingDate &gt;= @BeginningDate 
                                    AND dbo.tblJobPostings.ClosingDate &lt;= @EndingDate 
                                ORDER BY dbo.tblJobPostings.ClosingDate Asc">
            <SelectParameters>
                <asp:ControlParameter ControlID="txtBeginningDate" Name="BeginningDate" 
                    PropertyName="Text" ConvertEmptyStringToNull="False" DefaultValue="" />
                <asp:ControlParameter ControlID="txtEndingDate" Name="EndingDate" 
                    PropertyName="Text" ConvertEmptyStringToNull="False" DefaultValue="" />
            </SelectParameters>
        </asp:SqlDataSource>

        <asp:SqlDataSource ID="sqlDSJobReport" runat="server"></asp:SqlDataSource>

</asp:Content>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:23:50+00:00Added an answer on May 29, 2026 at 6:23 am

    I really don’t understand why this worked, but I decided to try handling the dates manually with session variables and its working perfectly now. It doesn’t matter if I mess with the session state on the update panels or any of the form elements it seems to work no matter what now.

    I guess that after the initial asyncpostback the sqldatasource wasn’t reading the values in the textboxes, or something. If anyone can explain what was going on in another “Answer Question” section I’ll accept it.

    If Page.IsPostBack Then
    
        Session("sBeginningDate") = txtBeginningDate.Text
        Sessoin("sEndingDate") = txtEndingDate.Text
    
        txtBeginningDate.Text = Session("sBeginningdate")
        txtEndingDate.Text = Session("sEndingDate")
    
    Else
    
        Session("sBeginningDate") = Now().AddDays(-14)
        Session("sEndingDate") = Now()
    
        txtBeginningDate.Text = Session("sBeginningDate").ToShortDateString
        txtEndingDate.Text = Session("sEndingDate").ToShortDateString
    
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Overview: I have an array of 20 byte strings that needs to be stored
I have a document that is an overview document within a folder, there are
Problem Overview: My application has an enrollment form. Users have a habit of entering
Sitation: overview: I have something like this: std::vector<SomeType> values; std::vector<int> indexes; struct Range{ int
I have a textarea tag that has text I want a user to edit.
Overview: I have two pages in my program; the main page and the other
I have a php page that creates page data from two .txt files (one
Basically, I have two classes : - MyActivity.java - OtherClass.java Overview of MyActivity.java :
I have a MainWindow with a table that shows all books in an overview.
I have two spreadsheets in Excel. Sheet1 is called Overview , and Sheet2 is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.