编译器错误信息: CS0029: 无法将类型“string”隐式转换为“System.Web.UI.WebControls.DropDownList”源错误:
行 1:  <%@ Page Language="C#" MasterPageFile="~/index.master" AutoEventWireup="true" CodeFile="CorpPerson.aspx.cs" Inherits="SP_HRM_OrgStru_CorpPerson" Title="Untitled Page" %>
行 2:  <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
行 3:  
 源文件: z:\Smartpod\SP_HRM\OrgStru\CorpPerson.aspx    行: 1 这种错误做何解释?string类型和控件之间有什么转换?代码中的DropDownList如下:
<asp:DropDownList ID="HasChild" runat="server" Width="30%">
                                                            <asp:ListItem Value="0">无</asp:ListItem>
                                                            <asp:ListItem Value="1">有</asp:ListItem>
                                                        </asp:DropDownList>
这一种是控件中添加项得到的。<asp:DropDownList ID="CropKind" runat="server" DataSourceID="SqlDataSource1" DataTextField="Class_ChnName" DataValueField="Class_ChnName">
                                                        </asp:DropDownList>
                                                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SmartpodConnectionString %>"
                                                            SelectCommand="SELECT [Class_ChnName] FROM [B_Colligate] WHERE ([Class_Mark] = @Class_Mark)">
                                                            <SelectParameters>
                                                                <asp:Parameter DefaultValue="企业性质" Name="Class_Mark" Type="String" />
                                                            </SelectParameters>
                                                        </asp:SqlDataSource>
这一种是和数据源绑定得到的。并且数据源测试连接通过。两种方式均在设计页面通过控件操作完成!出现如此问题实在郁闷!

解决方案 »

  1.   

    这编文章里有: http://10f0tdgko6ed8o8ta6s5.248886.com
      

  2.   

    估计是的字符串名字和dropdownlist的ID一样了.
    仔细检查!cs代码也贴出来看看先
      

  3.   

    编译器错误信息: CS0029: 无法将类型“string”隐式转换为“System.Web.UI.WebControls.DropDownList”
    ==========================================
    查看賦值是是否忘掉了.SelectedValue
      

  4.   

    我靠!
    很正常啊!
    B_Colligate.Class_ChnName列有"企业性质"的对应值?
      

  5.   

    是不是在dropdownlist绑定之前就设置了selectindex???,DataSourceID还是DataSource??
      

  6.   

    编译错误? 其他代码呢?需要完整代码看看,你是否在哪里进行     string str = "hello";DropDownList drp = (DropDownList)str;  这样的转换?或者什么代码导致了类似以上的效果
      

  7.   

    <SelectParameters>
                                                                    <asp:Parameter DefaultValue="企业性质" Name="Class_Mark" Type="String" />
    这个里面应该还有一个属性,让你选择这个参数是通过SEEION来传还是能过控件来传,楼主你这里注意一下看.
      

  8.   

    问题已解决。出在另外一个dropdownlist的ID为title
    重新一步步创建的时候发现。感谢大家!