Solved

cant get dropdown to fire SelectIndexChanged Event in dropdown in gridview row

Posted on 2008-06-17
3
759 Views
Last Modified: 2013-11-26
I have a dropdown list box as a template field in my gridview, and I can not get it to fire the selectedindexchanged event in my code behind file.

Here is my gridview code:
<ASP:GridView id="MyGridView" runat="server" Width="813px" Font-Size="9pt"      AutoGenerateColumns="False"      AllowPaging="True" AllowSorting="True" DataKeyNames="LeadID" PageSize="500" EmptyDataText="No Referred to Credit for You!!!!!">
    <Columns>    
        <asp:TemplateField HeaderText="Assign To Rep">
        <ItemTemplate>
            <asp:DropDownList ID="ddAssignRep" runat="server" DataSourceID="dsCRRep" AppendDataBoundItems="True" DataTextField="RepWholeName" DataValueField="CreditRepID" AutoPostBack="true" OnSelectedIndexChanged="ddAssignRep_SelectedIndexChanged">
            <asp:ListItem>Assign</asp:ListItem>
            </asp:DropDownList></ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField HeaderText="LoanID" SortExpression="LoanID" Datafield="LoanID" />    
        <asp:BoundField HeaderText="Borrower Name" Datafield="WholeName" />
        <asp:BoundField HeaderText="LO" Datafield="LOAssigned" />    
        <asp:BoundField HeaderText="Date To Credit Repair" Datafield="ReferredRepairDate" />    
        <asp:BoundField HeaderText="Loan Amount" Datafield="PreLoanAmt" />    
        <asp:BoundField HeaderText="Credit Scores" Datafield="CreditScores" />
        <asp:BoundField HeaderText="Your Note" Datafield="RepairRefNotes" />              
        <asp:BoundField HeaderText="Repair Referral Status" Datafield="RepairReferral" />    
    </Columns>  
    <AlternatingRowStyle BackColor="DimGray" />
</ASP:GridView>

Below is my code behind sub.

Protected Sub ddAssignRep_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        MsgBox("testing this")
    End Sub

And I never get the msgbox.  Ca someone clue me in as to why the page is postingback, but the event is not firing?  Is it because I have the page posting pack so it overrides the sub procedure call, and then when he page reloads it does not retain he value, but defaults back to the same index on the dropdown?  I am a bit lost here.  Thanks for any help.
0
Comment
Question by:wolfcoop
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Assisted Solution

by:ororiole
ororiole earned 100 total points
ID: 21808529
post your Page_Load code so we can take a look at it.
0
 

Author Comment

by:wolfcoop
ID: 21809475
is it is housed in a master page.  Dont know if that makes any difference.  Here is the page load event of the page.

Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs) Handles Me.Load

        If Session("UserID") = "" Or IsNothing(Session("UserID")) Then
            Response.Redirect("Login.aspx")
        End If

        objConnect = New SqlConnection()
        objConnect.ConnectionString = ConfigurationManager.ConnectionStrings("VACRMDEVConnectionString").ConnectionString
        Dim strUserName = Session("UserID")
        Dim datDate = Now()

        Dim sqlQuery As String = "SELECT ReferredRepairDate, LeadID, LoanID, LOAssigned, WholeName, PreLoanAmt, RepairReferral, LeadXPN + ', ' + LeadEFX + ', ' + LeadTUC AS [CreditScores], RepairRefNotes From CRMAppLoan WHERE CreditPulledDate >  '4/1/2008 12:00:00 AM'   AND RepairReferral IS NULL AND LoanStatus = 'Credit Repair' Order By LOAssigned"
        myDataAdapter = New SqlDataAdapter(sqlQuery, objConnect)
        'MsgBox(sqlQuery)
        If Not IsNothing(myDataAdapter) Then
            DS = New DataSet()

            myDataAdapter.Fill(DS, "MyGridView")
            Dim Source As DataView = DS.Tables(0).DefaultView
            MyGridView.DataSource = Source
            MyGridView.DataBind()
        End If
    End Sub
0
 

Accepted Solution

by:
wolfcoop earned 0 total points
ID: 21813395
I wrapped the thing in the not postback thingy and that fixed it.  My page load was binding to my grid everytime, thus not changing the index.  I am an idiot, but the ole Not Page.Ispostback fixed it.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question