DropDownList inside updatepanel not working well

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
8/31/2010 3:03:39 AM
Gravatar
Total Posts 55

DropDownList inside updatepanel not working well

Hi all,

 

I am using inside Update panel DropDownList and GridView, 

GridView data changes according to DropDownList selected index changed,

first postback everything is OK but after second postBack selected index does not change and merges all date

This user control does not work only inside mojoportal.

How can I solve thsi problem?

 

Thanks in advanced

8/31/2010 6:03:18 AM
Gravatar
Total Posts 55

Re: DropDownList inside updatepanel not working well

I have searched in the forum and solution looks to be Page.Form.Action = SiteUtils.GetCurrentPageUrl(); but it gives me error

How can I use in my .ascx file SiteUtils?

 

Thanks

8/31/2010 7:05:34 AM
Gravatar
Total Posts 18439

Re: DropDownList inside updatepanel not working well

Page.Form.Action = SiteUtils.GetCurrentPageUrl();

what error do you get when you use that code?

8/31/2010 7:17:17 AM
Gravatar
Total Posts 55

Re: DropDownList inside updatepanel not working well

 

Thank you Joe for quick reply, I dont know just how to use:

 

Error is like this:

CS0103: The name 'SiteUtils' does not exist in the current context

 

Thanks

8/31/2010 7:35:34 AM
Gravatar
Total Posts 18439

Re: DropDownList inside updatepanel not working well

You need to add a reference to the top of your UserControl

<%@ Import Namespace="mojoPortal.Web" %>

or if using Codebehind you need to add 

using mojoPortal.Web;

8/31/2010 7:43:30 AM
Gravatar
Total Posts 55

Re: DropDownList inside updatepanel not working well

Thanks no compilation error now but anyway postback has bug in update panel, postback second times is ok but

third times it retries all data in gridview instead... 

 

How can I fix it?

8/31/2010 7:53:19 AM
Gravatar
Total Posts 18439

Re: DropDownList inside updatepanel not working well

make sure you call that code every time page load event fires.

If you inspect the html with Firebug after each postback, look at the form action, if the form action is changed it causes this error, the code is designed to make sure form action stays the same.

However, it only works in .NET 3.5 SP1 or higher, it will not work in .NET 3.5 without the service pak.

8/31/2010 8:12:17 AM
Gravatar
Total Posts 55

Re: DropDownList inside updatepanel not working well

 anyway it is not working, maybe I am not using SiteUtils corectly

my code looks like this,

using System;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using mojoPortal.Web;
public partial class DisplayTeamTable : System.Web.UI.UserControl
{

    SqlConnection sqlConn = new SqlConnection("connectionstring");

    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Form.Action = SiteUtils.GetCurrentPageUrl();
        if (!IsPostBack) {
     //
dropDownSQLds.DataBind();
ChempDropDownMain.DataBind();
grdiViewSaturniroSQLdsBound();
}
}
protected void ChempDropDownMain_SelectedIndexChanged(object sender, EventArgs e)
{

grdiViewSaturniroSQLdsBound();
gridViewSaturniroCxrili.DataBind();

}
void grdiViewSaturniroSQLdsBound()
{
testLabel.Text = ChempDropDownMain.SelectedItem.Text;
gridViewSaturniroSQLds.SelectCommand = "select * from gffTeam where idGFFChemp=" + ChempDropDownMain.SelectedItem.Value + "ORDER BY gScores DESC";
gridViewSaturniroSQLds.DataBind();
}
}      

------------------------------------------------

<%@ Control Language="C#" AutoEventWireup="true" EnableViewState="true" CodeFile="DisplayTeamTable.ascx.cs" Inherits="DisplayTeamTable" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

 

   <div style="width:250px;margin:50px 0px 0px 0px;">
   <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
    <asp:DropDownList ID="ChempDropDownMain" runat="server" EnableTheming="false"
        DataSourceID="dropDownSQLds" DataTextField="NameGeo"
DataValueField="idGFFChemp" AutoPostBack="True" Width="250px"
onselectedindexchanged="ChempDropDownMain_SelectedIndexChanged">
</asp:DropDownList>




<asp:SqlDataSource ID="dropDownSQLds" runat="server"
ConnectionString="<%$ ConnectionStrings:MSSQLConnectionString %>"
SelectCommand="SELECT * FROM [gffChemp]"></asp:SqlDataSource>



<asp:GridView ID="gridViewSaturniroCxrili" EnableTheming="false" runat="server"
DataSourceID="gridViewSaturniroSQLds" AutoGenerateColumns="False"
DataKeyNames="idGFFTeam" CellPadding="4" ForeColor="#333333" Width="250px"
GridLines="None">
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:BoundField DataField="idGFFTeam" HeaderText="idGFFTeam"
Visible="False" ReadOnly="True" SortExpression="idGFFTeam"
InsertVisible="False" />
<asp:BoundField DataField="idGFFChemp" HeaderText="idGFFChemp"
Visible="False" SortExpression="idGFFChemp" />
<asp:TemplateField>
<ItemTemplate>
<asp:image ToolTip = "ASP Image Control" ID="Image4" runat="server" ImageUrl ='<%# "ImageCSharp.aspx?ImageID=" + DataBinder.Eval(Container.DataItem, "idGFFTeam") %>' Height="40px" Width="40px"></asp:image>

</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="NameGeo" HeaderText="გუნდი"
SortExpression="NameGeo" ItemStyle-Width=150px
ItemStyle-HorizontalAlign="Left" >
<ItemStyle HorizontalAlign="Left" Width="150px"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="gPlayed" HeaderText="თ"
SortExpression="gPlayed" ItemStyle-Width=20px ItemStyle-ForeColor="Red"
ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center" Width="20px"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="gScores" HeaderText="ქ" ItemStyle-Width=20px ItemStyle-HorizontalAlign="Center"
SortExpression="gScores" >
<ItemStyle HorizontalAlign="Center" Width="20px"></ItemStyle>
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="Red" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="gridViewSaturniroSQLds" runat="server"
ConnectionString="<%$ ConnectionStrings:MSSQLConnectionString %>"
SelectCommand="SELECT * FROM [gffTeam]"></asp:SqlDataSource>
<asp:Label ID="testLabel" runat="server" Text="Fotoer"></asp:Label>
</ContentTemplate>

</asp:UpdatePanel>
</div>  

8/31/2010 8:29:08 AM
Gravatar
Total Posts 18439

Re: DropDownList inside updatepanel not working well

Is the control used on a CMS page or a custom page. If a custom page then you may need to set the url for the action different than SiteUtils.GetCurrentPageUrl, that is only for CMS pages.

Best thing to do is use Firebug and find out what is happening to the form action after each ajax postback.

8/31/2010 9:04:17 AM
Gravatar
Total Posts 55

Re: DropDownList inside updatepanel not working well

I installed Firebug:

in dropDown list i have tree options, when first time page is loaded everything is OK,

when I am choosing in dropDown list second and third option everything is correctly displayed in Gridview,

but when I choose first option it shows all data together in Gridview for second and third option,

 

8/31/2010 9:21:39 AM
Gravatar
Total Posts 18439

Re: DropDownList inside updatepanel not working well

you should set a few break points in your code and step through it in the debugger to find out what is happening

You must sign in to post in the forums. This thread is closed to new posts.