Solved

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

Posted on 2008-06-17
3
757 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
  • 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

685 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