[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

11/05/2007 at 06:02AM PST, ID: 22938952
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.8

ASP.NET 2.0 SQL VB.NET Unbound Dropdownlist Gridview

Asked by accessloans in Programming for ASP.NET, Visual Studio

Tags: unbound, gridview, dropdownlist

I have a gridview that shows data from sql using a query. The query find the current month and year and displays cases for the current month. I have added two dropdownlists to my page. These are unbound. The first dropdownlist has the months in number format (01, 02, 03 etc). The second dropdownlist has the year which is worked with vb.net to add current year and three years previous (2007, 2006, 2005, 2004). I would like to be able to set the two dropdownlists to a month and year and have the gridview automatically change and show the cases for that month and year.

I cant figure out how to tie the dropdownlists to the query for unbound dropdownlists.

The code i have just now is -

VB.NET

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        lblmonth.Text = DateTime.Now.ToString("MMMM yyyy")

        If Not Page.IsPostBack Then
            Call Populate_MonthList()
            Call Populate_YearList()
        End If

    End Sub

    Sub Populate_MonthList()
        'Add each month to the list
        drpmonth.Items.Add("01")
        drpmonth.Items.Add("02")
        drpmonth.Items.Add("03")
        drpmonth.Items.Add("04")
        drpmonth.Items.Add("05")
        drpmonth.Items.Add("06")
        drpmonth.Items.Add("07")
        drpmonth.Items.Add("08")
        drpmonth.Items.Add("09")
        drpmonth.Items.Add("10")
        drpmonth.Items.Add("11")
        drpmonth.Items.Add("12")

        'Make the current month selected item in the list
        drpmonth.Items.FindByValue(DateTime.Now.Month).Selected = True

    End Sub

    Sub Populate_YearList()
        Dim intYear As Integer

        'Year list can be changed by changing the lower and upper
        'limits of the For statement    
        For intYear = DateTime.Now.Year - 3 To DateTime.Now.Year
            drpyear.Items.Add(intYear)
        Next

        'Make the current year selected item in the list
        drpyear.Items.FindByValue(DateTime.Now.Year).Selected = True
    End Sub

End Class


ASP.NET

<!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>Untitled Page</title>
</head>
<body style="text-align: left">
    <form id="form1" runat="server">
    <div style="text-align: center"> <asp:Label ID="lblmonth" runat="server" Font-Names="Verdana" Font-Size="14pt"></asp:Label>
        <br />
        <br />
        <asp:DropDownList ID="drpmonth" runat="server" Font-Names="Verdana" Font-Size="12pt" AutoPostBack="True">
        </asp:DropDownList>
        &nbsp; &nbsp;
        <asp:DropDownList ID="drpyear" runat="server" Font-Names="Verdana" Font-Size="12pt" AutoPostBack="True">
        </asp:DropDownList><br />
        <br />
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BC_BE_AccessConnectionString %>"
            SelectCommand="SELECT Lender.Company, COUNT(CaseProcessing.StatusID) AS Completed, SUM(vw_Case_CommissionTotal.CommissionIn) AS [Comm In], SUM(vw_Case_CommissionTotal.CommissionOut) AS [Comm Out], SUM(vw_Case_CommissionTotal.CommissionNet) AS [Comm Net] FROM CaseDetails INNER JOIN CaseProcessing ON CaseDetails.CaseID = CaseProcessing.CaseID INNER JOIN CaseUnderWriting ON CaseDetails.CaseID = CaseUnderWriting.CaseID INNER JOIN Lender ON CaseUnderWriting.LenderID = Lender.ID INNER JOIN vw_Case_CommissionTotal ON CaseProcessing.CaseID = vw_Case_CommissionTotal.caseid WHERE (MONTH(CaseProcessing.StatusDate) = MONTH(GETDATE())) AND (YEAR(CaseProcessing.StatusDate) = YEAR(GETDATE())) AND (CaseDetails.LoanTypeID = 8) AND (CaseProcessing.StatusID = 22) GROUP BY Lender.Company ORDER BY Lender.Company">
        </asp:SqlDataSource>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
            Width="850px">
            <Columns>
                <asp:BoundField DataField="Company" HeaderText="Company" HtmlEncode="False" SortExpression="Company">
                    <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Width="330px" />
                </asp:BoundField>
                <asp:BoundField DataField="Completed" HeaderText="Completed" ReadOnly="True" SortExpression="Completed">
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="130px" />
                </asp:BoundField>
                <asp:BoundField DataField="Comm In" DataFormatString="{0:C}" HeaderText="Comm In"
                    HtmlEncode="False" ReadOnly="True" SortExpression="Comm In">
                    <ItemStyle HorizontalAlign="Right" VerticalAlign="Middle" Width="130px" />
                </asp:BoundField>
                <asp:BoundField DataField="Comm Out" DataFormatString="{0:C}" HeaderText="Comm Out"
                    HtmlEncode="False" ReadOnly="True" SortExpression="Comm Out">
                    <ItemStyle HorizontalAlign="Right" VerticalAlign="Middle" Width="130px" />
                </asp:BoundField>
                <asp:BoundField DataField="Comm Net" DataFormatString="{0:C}" HeaderText="Comm Net"
                    HtmlEncode="False" ReadOnly="True" SortExpression="Comm Net">
                    <ItemStyle HorizontalAlign="Right" VerticalAlign="Middle" Width="130px" />
                </asp:BoundField>
            </Columns>
        </asp:GridView>
    </div>
    </form>
</body>
</html>
[+][-]11/05/07 07:17 AM, ID: 20216684

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, Visual Studio
Tags: unbound, gridview, dropdownlist
Sign Up Now!
Solution Provided By: valkyrie_nc
Participating Experts: 1
Solution Grade: A
 
 
[+][-]11/05/07 07:56 AM, ID: 20216989

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 / EE_QW_2_20070628