Solved

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

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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Securing WEBAPI on Azure 2 55
c#, case, if 4 37
search by any word in column 5 29
Help with viewing images in an MSReport using a Dataset using VB.NET 29 27
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:…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
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…

732 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