输入的字符串格式不正确 AjaxControlToolkit
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CartTwo.ascx.cs" Inherits="Controls_CartTwo" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="CartTwoAjax" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
<div class="flowBox">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <table width="99%" align="center" border="0">
        <tbody>
            <tr>
                <td bgcolor="#ffffff">
                    送货方式及运费</td>
                <td bgcolor="#ffffff" colspan="3">
                    <asp:DropDownList ID="distric" runat="server">
                        
                    </asp:DropDownList>
                    <asp:DropDownList ID="delivery" AutoPostBack="true" OnSelectedIndexChanged="delivery_SelectedIndexChanged"
                        runat="server">
                    </asp:DropDownList>
                    
                    <CartTwoAjax:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="distric"
                        ServicePath="~/Ajax/GetDeliverys.asmx" ServiceMethod="GetAddress" Category="categoryid"
                        PromptValue="0" ParentControlID="" LoadingText="加载地区.." PromptText="请选择地区">
                    </CartTwoAjax:CascadingDropDown>
                    <CartTwoAjax:CascadingDropDown ID="CascadingDropDown2" runat="server" TargetControlID="delivery"
                        ServicePath="~/Ajax/GetDeliverys.asmx" ServiceMethod="GetType" Category="deliveryid"
                        ParentControlID="distric" LoadingText="加载方式.." PromptText="请选择方式">
                    </CartTwoAjax:CascadingDropDown>
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" RenderMode="inline">
                        <ContentTemplate>
                            <asp:Label ID="weightmoney" runat="server" Text=""></asp:Label>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="delivery" EventName="SelectedIndexChanged" />
                        </Triggers>
                    </asp:UpdatePanel>
                    <%--¥<font color="red"><asp:Label ID="weightmoney" runat="server" Text=""></asp:Label></font>元
                    (必填)--%>
                </td>
            </tr>
            <tr>
                <td bgcolor="#ffffff">
                    商品重量</td>
                <td bgcolor="#ffffff">
                    &nbsp;
                    <asp:Label ID="weight" runat="server" Text=""></asp:Label>
                    KG</td>
                <td bgcolor="#ffffff">
                    电子邮件地址:</td>
                <td bgcolor="#ffffff">
                    <asp:TextBox ID="useremail" class="inputBg" runat="server"></asp:TextBox>
                    (必填)</td>
            </tr>
            <tr>
                <td bgcolor="#ffffff">
                    收货人</td>
                <td bgcolor="#ffffff">
                    <asp:TextBox ID="recepit" class="inputBg" runat="server"></asp:TextBox>
                    (必填)</td>
                <td bgcolor="#ffffff">
                    性别</td>
                <td bgcolor="#ffffff">
                    <asp:DropDownList ID="usersex" runat="server">
                        <asp:ListItem Value="1">男</asp:ListItem>
                        <asp:ListItem Value="2">女</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td bgcolor="#ffffff">
                    地址</td>
                <td bgcolor="#ffffff">
                    <asp:TextBox ID="useraddr" class="inputBg" runat="server"></asp:TextBox>
                    (必填)</td>
                <td bgcolor="#ffffff">
                    邮编</td>
                <td bgcolor="#ffffff">
                    <asp:TextBox ID="userpost" class="inputBg" runat="server"></asp:TextBox></td>
            </tr>
            <tr>
                <td bgcolor="#ffffff">
                    联系方式</td>
                <td bgcolor="#ffffff">
                    <asp:TextBox ID="usertel" class="inputBg" runat="server"></asp:TextBox>
                    (必填)</td>
                <td bgcolor="#ffffff">
                    支付方式:</td>
                <td bgcolor="#ffffff">
                    <asp:DropDownList ID="payment" runat="server">
                    </asp:DropDownList>
                    <span>&nbsp;&nbsp;<a href="Help.aspx?ID=10">查看详细介绍>></a> </span>
                </td>
            </tr>
            <tr>
                <td bgcolor="#ffffff">
                    备注</td>
                <td bgcolor="#ffffff" colspan="3">
                    <textarea class="inputstyle" id="comments" cols="30" runat="server" rows="5"></textarea></td>
            </tr>
            <tr>
                <td align="center" bgcolor="#ffffff" colspan="4">
                    <asp:Button ID="AddOrder" class="bnt_blue_2" runat="server" Text="提交订单" OnClick="AddOrder_Click">
                    </asp:Button>
                </td>
            </tr>
        </tbody>
    </table>
</div>当我选中delivery的老是爆出输入的字符串格式不正确错误求教了。

解决方案 »

  1.   


    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>  
       
     <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>  
       
     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">  
     <html xmlns="http://www.w3.org/1999/xhtml">  
     <head runat="server">  
         <title>AJAX控件之AutoComplete</title>  
     </head>  
     <body style="text-align: center">  
        <form id="form1" runat="server">  
             <asp:ScriptManager ID="ScriptManager1" runat="server" />  
             <div>  
                 <asp:TextBox ID="MyAuto" runat="server" Width="191px"></asp:TextBox><br />  
                 <br />  
                 <cc1:AutoCompleteExtender ID="ace" runat="server" CompletionInterval="100" MinimumPrefixLength="1"  
                     ServiceMethod="GetCompletionList" ServicePath="WebService.asmx" TargetControlID="MyAuto">  
                 </cc1:AutoCompleteExtender>  
                 &nbsp;</div>  
         </form>  
    </body>  
    </html>  # using System;  
     using System.Web;  
     using System.Collections.Generic;  
     using System.Web.Services;  
     using System.Web.Services.Protocols;  
       
       
     /// <summary>  
     /// WebService 的摘要说明  
     /// </summary>  
     [WebService(Namespace = "http://tempuri.org/")]  
     [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]  
     //用以调用Web Service方法签名  
     [System.Web.Script.Services.ScriptService]  
     public class WebService : System.Web.Services.WebService {  
       
         public WebService () {}  
       
         [WebMethod]  
         public string[] GetCompletionList(string prefixText, int count)  
         {  
             //if (count == 0)  
             //{  
             //    count = 10;  
             //}  
             Random random = new Random();  
             List<string> items = new List<string>(count);  
             for (int i = 0; i < count; i++)  
             {  
                 char c1 = (char)random.Next(65,90);  
                 char c2 = (char)random.Next(97, 122);  
                 char c3 = (char)random.Next(48, 57);  
                 char c4 = (char)random.Next(33, 43);  
                 items.Add(prefixText + c1 + c2 + c3 + c4);  
             }  
             return items.ToArray();  
         }  
       
    }  
      

  2.   

    不太明白啊,我怎么改成dropdownlist用的啊
      

  3.   


     <asp:DropDownList ID="Txb_studentTechPro" runat="server">
                                        </asp:DropDownList>
                                        <ajaxToolkit:CascadingDropDown ID="CascadingDropDown3" runat="server" Category="province"
                                            LoadingText="正在载入省份...." PromptText="请选择省份" TargetControlID="Txb_studentTechPro"
                                            ServiceMethod="GetProvince">
                                        </ajaxToolkit:CascadingDropDown>
                                        <asp:DropDownList ID="Txb_studentTechCity" runat="server">
                                        </asp:DropDownList>
                                        <ajaxToolkit:CascadingDropDown ID="CascadingDropDown4" runat="server" Category="city"
                                            LoadingText="正在载入城市...." ParentControlID="Txb_studentTechPro" PromptText="请选择城市"
                                            TargetControlID="Txb_studentTechCity" ServiceMethod="GetProvince">
                                        </ajaxToolkit:CascadingDropDown>
                                        <asp:DropDownList ID="Txb_studentArea"  
                                            runat="server">
                                        </asp:DropDownList>
                                        <ajaxToolkit:CascadingDropDown ID="CascadingDropDown5" runat="server" Category="area"
                                            LoadingText="正在载入区划...." ParentControlID="Txb_studentTechCity" PromptText="请选择区划"
                                            TargetControlID="Txb_studentArea" ServiceMethod="GetProvince">
                                        </ajaxToolkit:CascadingDropDown>
      /// <summary>
        /// 区域下拉框三级联动数据获取
        /// </summary>
        /// <param name="knownCategoryValues">所有父控件的已选值</param>
        /// <param name="category">下拉框控件的category属性值</param>
        /// <returns></returns>
        [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
        public static CascadingDropDownNameValue[] GetProvince(string knownCategoryValues, string category)
        {        //        // 如果采用了webService架构,这里就直接去调用webService中的[webMethod],07年6月份后的版本默认都不采用webService        // 而是直接将webService中的[webMethod]实现移动到这个方法体内        //
            
            
                string[] categoryValues = knownCategoryValues.Split(':', ';');
                List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
                areaDataContext info = new areaDataContext();
                switch (category)
                {
                    case "province":
                        IQueryable<province> infoMan = from province in info.province
                                                       select province;
                        List<province> infoManList = infoMan.ToList();
                        foreach (province i in infoManList)
                        {
                            values.Add(new CascadingDropDownNameValue(i.province1, i.provinceID));
                        }
                        break;
                    case "city":
                        IQueryable<city> infoMancity = from city in info.city
                                                       where city.father == categoryValues[1]
                                                       select city;
                        List<city> infoMancityList = infoMancity.ToList();
                        foreach (city i in infoMancityList)
                        {
                            values.Add(new CascadingDropDownNameValue(i.city1, i.cityID));
                        }
                        break;
                    case "area":
                        IQueryable<area> infoManarea = from area in info.area
                                                       where area.father == categoryValues[3]
                                                       select area;
                        List<area> infoManareaList = infoManarea.ToList();
                        foreach (area i in infoManareaList)
                        {
                            values.Add(new CascadingDropDownNameValue(i.area1, i.areaID));
                        }
                        break;
                }
                if (values.Count == 0)
                {                values.Add(new CascadingDropDownNameValue("无", "无"));            }
                return values.ToArray();
            
           
        }