Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
WebDropdown ItemsRequested event raises "Async request failed"
posted

Hi,

I tried to use webdropdown cascade sample but I got "Async request failed" message on my chrome browser.

My intended implemtation case is like this:

an user clicks and select a cell value on the main webdatagrid.( i assumed it simply by using a textbox)

the click invoke a webdropdown's loaditems and then itemsrequest event.

on the server data will be queried and bound to the webdropdown again with the selected value.

==> but I get "Async request failed" message.

plz review my code and check what i'm missing. thank you.

===================================================

    <script>
        function SetDropDown() {
            var wcQuestion= $find("<%= wcQuestion.ClientID %>");  
            wcQuestion.loadItems(form1.TextBox1.value);
        }

    </script>
<body>
    <form id="form1" runat="server">
    <div>
                        <asp:ScriptManager ID="ScriptManager1" runat="server">
                        </asp:ScriptManager>
                <div id="countContainer" class="controlPanel">
                    <div id="eventList" class="controlPanelEvent">
                        <br/>
                        <br/>
                        <ig:WebDropDown ID="wcQuestion" runat="server" Width="120px" Height="22px" Font-Size="8pt" Font-Names="Verdana"
                            BackColor="White" BorderColor="LightGray" BorderWidth="1px"
                            TextField="QuestionName" ValueField="ID"
                            EnableAutoCompleteFirstMatch="false" EnableDropDownAsChild="false" EnableAnimations="false"
                            OnItemsRequested="wcQuestion_ItemsRequested" >
                            <Items>
                                <ig:DropDownItem Key="ID" Selected="False" Text="DropDown Item" Value="" Visible="False">
                                </ig:DropDownItem>
                                <ig:DropDownItem Key="iFormObjectId" Selected="False" Text="DropDown Item" Value="" Visible="False">
                                </ig:DropDownItem>
                                <ig:DropDownItem Key="SCORE" Selected="False" Text="DropDown Item" Value="" Visible="False">
                                </ig:DropDownItem>
                                <ig:DropDownItem Key="nvcColor" Selected="False" Text="DropDown Item" Value="" Visible="False">
                                </ig:DropDownItem>
                                <ig:DropDownItem Key="QuestionName" Selected="False" Text="배점항목명" Value="QuestionName">
                                </ig:DropDownItem>
                            </Items>
                            <DropDownItemBinding TextField="QuestionName" ValueField="ID"></DropDownItemBinding>
                        </ig:WebDropDown>
                        <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="SetDropDown();" />
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

                    </div>
                </div>
====================================================================
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                wcQuestion_DataBinding();
            }
        }

        private void wcQuestion_DataBinding()
        {

            string strSql = "";

            SqlConnection Con = null;
            DataSet dsQuestion = new DataSet();
            SqlDataAdapter dataAdapter;

            try
            {
                strSql = strSql + "SELECT iQuestionId AS ID, iFormObjectId, fQuestionScore AS SCORE, nvcColor, QuestionName ";
                strSql = strSql + "  FROM (SELECT fq.iQuestionId, fq.iFormObjectId, fq.iQuestionOrder, fq.fQuestionScore, q.nvcColor, q.nvcQuestionTypeName + '(' + Convert(varchar, fq.fQuestionScore) + ')' AS QuestionName ";
                strSql = strSql + "          FROM tblFormQuestion fq, tblQuestionType q ";
                strSql = strSql + "         WHERE fq.iFormId = 5";
                strSql = strSql + "           AND fq.iQuestionTypeId = q.iQuestionTypeId) AS A ";
                if (TextBox1.Text != "")
                    strSql = strSql + "WHERE QuestionName like '" + TextBox1.Text + "%'";
                strSql = strSql + "ORDER BY iQuestionOrder ";

                Con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["CONNECTSTR"]);
                Con.Open();

                dataAdapter = new SqlDataAdapter(strSql, Con);
                dataAdapter.Fill(dsQuestion, "FORMQUESTION");
                wcQuestion.DataSource = dsQuestion.Tables["FORMQUESTION"].DefaultView;
                wcQuestion.Items.Clear();
                wcQuestion.DataBind();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (Con != null && Con.State == ConnectionState.Open)
                    Con.Close();

                Con = null;
            }

        }

        protected void wcQuestion_ItemsRequested(object sender, DropDownItemsRequestedEventArgs e)
        {
            wcQuestion_DataBinding();
        }