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
Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

839 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