简体   繁体   中英

metabuilder checked listbox selected index changed not working on server

am using meta builder checked listbox and their selected index changed working fine in local.but not working on server side. please help me to fix this error. My partial code is here..

    protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{

    try
    {
        if (ListBox1.Items.Count > 0)
        {
            for (int i = 0; i <= ListBox1.Items.Count; i++)
            {
                if (ListBox1.Items[i].Selected == true)
                {
                    lblempid.Text = Convert.ToString(ListBox1.Items[i].Text.Substring(0, 8));
                    lblempname.Text = Convert.ToString(ListBox1.Items[i].Text.Substring(9));
                    DataSet5TableAdapters.sp_GetallpayperiodTableAdapter TA = new DataSet5TableAdapters.sp_GetallpayperiodTableAdapter();
                    DataSet5.sp_GetallpayperiodDataTable DS = TA.GetData();
                    if (DS.Rows.Count > 0)
                    {
                        fromdate = Convert.ToString(DS.Rows[DS.Rows.Count - 1]["fldstartdate"]);
                        todate = Convert.ToString(DS.Rows[DS.Rows.Count - 1]["fldtodate"]);
                        status = Convert.ToString(DS.Rows[DS.Rows.Count - 1]["fldstatus"]);
                        if (status == "OPEN")
                        {
                            lblfromdate.Text = Convert.ToString(Convert.ToDateTime(fromdate).ToShortDateString());
                            lbltodate.Text = Convert.ToString(Convert.ToDateTime(todate).ToShortDateString());
                        }
                    } 

                }
            }
        }

    }
    catch (Exception e1)
    {
        ScriptManager.RegisterStartupScript(this, this.GetType(), "onload", "<script language='javascript'>alert('" + e1.Message + "');</script>", false);
    }

Design code:

       <%@ Register Assembly="MetaBuilders.WebControls" Namespace="MetaBuilders.WebControls"
TagPrefix="mb" %>

        <mb:CheckedListBox ID="ListBox1" runat="server" CssClass="textbox" Width="250px"
                                                                            Height="515px" AutoPostBack="True" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged">
                                                                        </mb:CheckedListBox>

please check if the auto post back is true in your aspx code: Example:

<asp:DropDownList ID="ddlForecastOption" runat="server" 
      onselectedindexchanged="ddlForecastOption_SelectedIndexChanged" 
      AutoPostBack="true">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM