Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 693
  • Last Modified:

Dropdown change cause gridview to loose data and selected index change doesn't fire

I changed the selection from my dropdown:
my selectedindex change does not get fired.
first time it keeps my selection on the gridview.
if i change dropdown again i loose selection and it resets my dropdown.
part of data does not get set on my gridview.


usercontrol 1 =========================================================
pageload
if not ispostback then
MainGridView.datasource = ds
MainGridView.databind()
end if
 
code:
If e.Row.RowType = DataControlRowType.DataRow Then 
 Dim myrow As GridViewRow = e.Row
 
                        If e.Row.RowIndex = 0 Then
                            Dim ucg As UCGridview
                            ucg = CType(myrow.FindControl("Details"), UCGridview)
 
                            Dim detgridview As GridView = CType(ucg .FindControl("detailsGridview"), GridView)
                            detgridview .DataSource = ds
                            detgridview .DataKeyNames = New String() {"ID"}
                            detgridview .DataBind()
                          End If
end if
markup
<asp:GridView ID="MainGridView" runat="server" AutoGenerateColumns="false" EnableViewState="true">
                    <Columns>
                        <asp:TemplateField ItemStyle-VerticalAlign="Top" HeaderText="MainHeading">
                            <ItemTemplate>
                                <uc:DetailsID="Details" runat="server" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
 
UCGridview =====================================================================
markup part:
<asp:TemplateField ItemStyle-VerticalAlign="Top" HeaderText="Products" Visible="True">
            <ItemTemplate>
            <asp:UpdatePanel runat="server" ID="ProductsDropDownListUpdatePanels" UpdateMode="Conditional">
                <ContentTemplate>
                <asp:DropDownList ID="Products" runat="server" EnableViewState="true" AppendDataBoundItems="true"
                    AutoPostBack="true">
                    <asp:ListItem Text="1">1</asp:ListItem>
                    <asp:ListItem Text="2">2</asp:ListItem>
                   </asp:DropDownList>
                </ContentTemplate>
            </asp:UpdatePanel>
                
            </ItemTemplate>
        </asp:TemplateField>
Code:
    Private Sub ProductsDropDownList_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ProductsDropDownList.SelectedIndexChanged
 
    End Sub

Open in new window

0
Padre_Corleone
Asked:
Padre_Corleone
1 Solution
 
jinalCommented:
Hello ,

In order to SelectedIndexChanged fired need to set AutoPostBack = true for DropDownList. Please set that and test.
0
 
Padre_CorleoneAuthor Commented:
the issue was that every dropdown change, i was reloading this User control.  avoiding reloading of control also avoided that not firing event. thanks!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now