On Dec 27, 9:49 am, "John Kotuby"
<JohnKot...@discussions.microsoft.com> wrote:
> Hi guys,
>
[quoted text clipped - 30 lines]
>
> TIA
Hi,
When you are using update panel. Is the process not fast. Sorry will
you please explain more.
Thanks
Net
John Kotuby - 27 Dec 2007 21:42 GMT
Hi dev,
Here is the code in my ASPX page where I am using the Update panel.
------------------------------------------------------------------
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePartialRendering="true">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table class="TblSearch" width="98%" cellpadding="0" cellspacing="0"
border="0">
<tr>
<td align="center" style=" width:30%" >
<asp:ListBox ID="lstCategoryType" SelectionMode="Single" runat="server"
CssClass="txt95"
OnSelectedIndexChanged="lstCategoryType_SelectedIndexChanged"
AutoPostBack="true" Rows="6">
</asp:ListBox>
</td>
<td align="center" style=" width:70%" >
<asp:ListBox ID="lstCategories" SelectionMode="Multiple" runat="server"
Rows="6" CssClass="txt95"></asp:ListBox>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
------------------------------------------------------------------
Note that in the ListBox ID="lstCategoryType" I have set
AutoPostback="True", because if I don't do that the update of the 2nd
listbox does not appear to occur. I have also set
OnSelectedIndexChanged="lstCategoryType_SelectedIndexChanged". Also I have
EnablePartialPageRendering="true" in the ScriptManager.
There are about 40 other controls on this page that are NOT in the
UpdatePanel.
Now here is the Code Behind method I wish to run:
---------------------------------------------------------------
Protected Sub lstCategoryType_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs)
'Load the lstCategories ListBox according to the selected CategoryType
Dim lstValue, lstText As String
Dim MyConnection As New SqlConnection
Dim MyCommand As New SqlCommand
Dim MyAdapter As New SqlDataAdapter
Dim CatTable As New DataTable
MyConnection.ConnectionString =
ConfigurationManager.ConnectionStrings("PCConnectionString").ConnectionString
MyConnection.Open()
MyCommand.CommandType = CommandType.Text
MyCommand.Connection = MyConnection
MyCommand.CommandText = "Select code,description from CategoryTable
with(nolock)where " & _
" categorytype ='" & Me.lstCategoryType.SelectedValue & "' order by
description "
MyAdapter.SelectCommand = MyCommand
MyAdapter.Fill(CatTable)
Me.lstCategories.Items.Clear()
For Each row As DataRow In CatTable.Rows
lstValue = row.Item("code").ToString
lstText = row.Item("description").ToString & " (" &
row.Item("code").ToString + ")"
Me.lstCategories.Items.Add(New ListItem(lstText, lstValue))
Next
MyAdapter.Dispose()
MyCommand.Dispose()
MyConnection.Dispose()
CatTable.Dispose()
End Sub
---------------------------------------------------------------
Now If I could get only that method to run and populate just the
lstCategories listbox that would be great. But it appears that a lot of
other code is also running because the refresh of the data in the listbox is
slow. It takes 5 seconds to refresh. Remember there are 40 other server
controls on this page that are outside of the Update Panel.
I compare the refresh time to a much smaller page with only 6 server
controls on it, all in an update panel, and the code-behind (that handles
the SelectedIndexChanged event) is almost identical. This page takes less
than 1 second to refresh the listbox.
Same database, same query, same web server. The slow page, like I said,
simply has many more controls on it, but only the 2 listboxes are in the
Update Panel.
> On Dec 27, 9:49 am, "John Kotuby"
> <JohnKot...@discussions.microsoft.com> wrote:
[quoted text clipped - 46 lines]
> Thanks
> Net