Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdown inside update panel inside template field inside gridview

Status
Not open for further replies.

NuJoizey

MIS
Aug 16, 2006
450
US
I have a gridview in which one of the fields is a dropdown that runs an update routine affecting data based on an ID in its same row on dd_SelectedIndexChanged. It works, but the problem is that the peformance is bad - the screen seems to lock up for 2-10 seconds after the the dd is updated.

The gridview holds about 2200 records, and I wish to avoid using paging, and avoid having to repost the entire page because it's slow, and the user's position is lost on the page. I just want people to scroll down, find the records that apply to them (usually sequential) and update them quickly one by one.

Can anyone tell me why the perforance is so bad on this page - and what might be a better way?

Code:
<asp:ScriptManager ID="ScriptManager1" runat="server"  EnablePartialRendering="true">
                        </asp:ScriptManager>
<asp:TemplateField HeaderText="PlacementName" >
                    <ItemTemplate>
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >
                            <ContentTemplate >
                                <asp:DropDownList ID="ddPlacementNames" runat="server" DataSourceID="dsPlacementNames" DataTextField="PlacementName" 
                                    DataValueField="PlacementNameID" AutoPostBack="true" AppendDataBoundItems="true"  OnSelectedIndexChanged="ddPlacementNames_OnSelectedIndexChanged" >
                                    <asp:ListItem Enabled="true" Selected="true" Text="Select..." Value="0" />
                                </asp:DropDownList>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                        <asp:HiddenField ID="HiddenField1" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>

here is the vb codebehind:

Code:
    Sub ddPlacementNames_OnSelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim DVta As New DV1TableAdapters.PLACEMENTTableAdapter
        Dim gvr As GridViewRow = sender.parent.parent.parent.parent
        Dim dd As DropDownList = gvr.Cells(8).FindControl("ddPlacementNames")
        Dim intPlacementID As Integer = gvr.Cells(0).Text
        Dim intNewValue As Integer = dd.SelectedValue
        Dim upd As UpdatePanel = gvr.Cells(8).FindControl("UpdatePanel1")

        If dd.SelectedValue <> 0 Then
            DVta.UpdatePlacementNameByPlacementID(intNewValue, intPlacementID)
        End If

    End Sub



    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

        Dim gv As GridView = sender
        Dim gvr As GridViewRow = e.Row

        Dim dd As DropDownList
        Dim DVta As New DV1TableAdapters.PLACEMENTTableAdapter
       
        If IsPostBack = False Then

            If gvr.RowType = DataControlRowType.DataRow Then
                dd = gvr.Cells(8).FindControl("ddPlacementNames")
                dd.SelectedValue = DVta.GetPlacementNameIDByPlacementName(gvr.Cells(0).Text)
            End If
        End If

    End Sub
 
The performance is bad because you are showing 2200 records. Everytime you go in and out of edit/update mode, you are quering the db and bringing back, and rendering 2200 rows.
 
i figured as much, but isn't there a way to tell it to just run the update query and not have to refresh the entire screen? That's what I thought I was doing with the AJaX update panel, but i guess not.

the way I'm trying to work around it now is to disable postback on the SelectedIndex changed, and have the user make all the changes and then hit a submit button. But I feel like I shouldn't have to do that, know what I mean?
 
I haven't used the AJAX objects that come with Visual Studio. As far as I understand, when using the update panels, the whole page is still posted back, and only what it is in the panel is refreshed.
Any AJAX stuff I have done, I have used the ICallBack Interface. Here is an article on the Update Panel:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top