Solved

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

Posted on 2008-06-17
3
752 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
Comment Utility
post your Page_Load code so we can take a look at it.
0
 

Author Comment

by:wolfcoop
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
DLL in ASP.NET 20 38
Convert string to date 3 38
Asp.net mvc entity issue 6 18
Get list of word ducuments in a folder 10 9
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now