在模板化控件中实现级联 DropDownList 绑定

发布于 2024-11-25 05:20:03 字数 3125 浏览 1 评论 0原文

我的表单上有 2 个 DropDownList 控件,其中第二个控件使用第一个控件的 SelectedValue 作为其绑定参数之一。

两个 DropDownList 控件均位于 FormView.InsertItemTemplate 中,并使用 Binding 将 SelectedValue 属性绑定到 FormView 的数据源表达。

第一次 FormView 在插入模式下呈现时,一切正常。问题是在第一个 DropDownList 执行 AutoPostBack 之后,FormView 不会(重新)绑定,但是由于 ControlParameter第二个 DropDownList 上的 已更改,它确实绑定(按预期),但第二个 DDL 的绑定表达式上发生异常,我假设是因为 FormView > 不具有约束力在该通行证上:

System.InvalidOperationException:数据绑定方法,例如 Eval()、 XPath() 和 Bind() 只能在数据绑定的上下文中使用 控制。

这是标记:

<InsertItemTemplate>
.
.
.
<tr class="GridViewRowB">
                    <td class="GridViewCell">
                        Offense Type
                    </td>
                    <td class="GridViewCell">
                        <asp:DropDownList ID="ddlOffenseType" runat="server" DataSourceID="dsOffenseType"
                            AutoPostBack="true" DataValueField="OffenseTypeID" DataTextField="Description"
                            SelectedValue='<%# Bind("OffenseTypeID") %>'>
                        </asp:DropDownList>
                        <asp:ObjectDataSource ID="dsOffenseType" runat="server" TypeName="OffenseType"
                            SelectMethod="GetAll">
                            <SelectParameters>
                                <asp:Parameter Name="ActiveOnly" DefaultValue="True" Type="Boolean" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                    </td>
                </tr>
                <tr class="GridViewRowA">
                    <td class="GridViewCell">
                        Attorney
                    </td>
                    <td class="GridViewCell">
                        <asp:DropDownList ID="ddlAttorney" runat="server" DataSourceID="dsAttorney" DataValueField="AttorneyID"
                            DataTextField="AttorneyNameWithCount" SelectedValue='<%# Bind("AttorneyID") %>'>
                        </asp:DropDownList>
                        <asp:ObjectDataSource ID="dsAttorney" runat="server" TypeName="Attorney"
                            SelectMethod="GetAttorneyWithCaseCount">
                            <SelectParameters>
                                <asp:Parameter Name="ActiveOnly" DefaultValue="True" Type="Boolean" />
                                <asp:ControlParameter Name="OffenseTypeID" Type="Int32" ControlID="ddlOffenseType"
                                    PropertyName="SelectedValue" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                    </td>
                </tr>
.
.
.
</InsertItemTemplate>

我的问题是:使此功能发挥作用的最佳方法是什么?是否可以将两个 DDL 保留在模板内?我宁愿避免使用 AJAX 工具包或其他客户端解决方案。

I have 2 DropDownList controls on my form, the second of which uses the SelectedValue of the first as one of its binding parameters.

Both DropDownList controls are in a FormView.InsertItemTemplate with SelectedValue properties bound to the FormView's datasource using a Binding Expression.

The first time the FormView renders in Insert mode, everything works fine. The problem is after an AutoPostBack from the first DropDownList, the FormView doesn't (re-)bind, however since the ControlParameter on the second DropDownList has changed, it DOES bind (as intended), but an exception occurs on the Binding Expression of the second DDL, I assume since the FormView is not binding on that pass:

System.InvalidOperationException: Databinding methods such as Eval(),
XPath(), and Bind() can only be used in the context of a databound
control.

Here is the markup:

<InsertItemTemplate>
.
.
.
<tr class="GridViewRowB">
                    <td class="GridViewCell">
                        Offense Type
                    </td>
                    <td class="GridViewCell">
                        <asp:DropDownList ID="ddlOffenseType" runat="server" DataSourceID="dsOffenseType"
                            AutoPostBack="true" DataValueField="OffenseTypeID" DataTextField="Description"
                            SelectedValue='<%# Bind("OffenseTypeID") %>'>
                        </asp:DropDownList>
                        <asp:ObjectDataSource ID="dsOffenseType" runat="server" TypeName="OffenseType"
                            SelectMethod="GetAll">
                            <SelectParameters>
                                <asp:Parameter Name="ActiveOnly" DefaultValue="True" Type="Boolean" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                    </td>
                </tr>
                <tr class="GridViewRowA">
                    <td class="GridViewCell">
                        Attorney
                    </td>
                    <td class="GridViewCell">
                        <asp:DropDownList ID="ddlAttorney" runat="server" DataSourceID="dsAttorney" DataValueField="AttorneyID"
                            DataTextField="AttorneyNameWithCount" SelectedValue='<%# Bind("AttorneyID") %>'>
                        </asp:DropDownList>
                        <asp:ObjectDataSource ID="dsAttorney" runat="server" TypeName="Attorney"
                            SelectMethod="GetAttorneyWithCaseCount">
                            <SelectParameters>
                                <asp:Parameter Name="ActiveOnly" DefaultValue="True" Type="Boolean" />
                                <asp:ControlParameter Name="OffenseTypeID" Type="Int32" ControlID="ddlOffenseType"
                                    PropertyName="SelectedValue" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                    </td>
                </tr>
.
.
.
</InsertItemTemplate>

My question is: What is the best way to make this functionality work? Is it possible to keep both DDL's inside the template? I would prefer to avoid using the AJAX toolkit or other client-side solutions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

谈情不如逗狗 2024-12-02 05:20:03

当我们在数据绑定控件(如 DetailsView/FormView)中使用级联下拉列表时,这是一个问题,我已经遇到过很多次了。您必须从第二个下拉列表 SelectedValue='<%# Bind("AttorneyID") %>' 中删除绑定表达式,然后它才会起作用。

其次,如果删除 Binding 表达式,则必须在 FormView ItemInserting 事件中手动传递值。例如

 protected void frmAsset_ItemInserting(object sender, FormViewInsertEventArgs e)
 {
    eValues["AttorneyID"] = ((DropDownList)((FormView)sender).FindControl("ddlAttorny")).SelectedValue;
 }

This is an issue when we use cascading dropdownlist in Databinding Controls like DetailsView/FormView and I have faced it many times. You have to remove the Binding Expression from your Second Dropdownlist SelectedValue='<%# Bind("AttorneyID") %>', then it will work.

Secondly if you remove the Binding expression, you have to pass the value manually in FormView ItemInserting Event. e.g.

 protected void frmAsset_ItemInserting(object sender, FormViewInsertEventArgs e)
 {
    eValues["AttorneyID"] = ((DropDownList)((FormView)sender).FindControl("ddlAttorny")).SelectedValue;
 }
°如果伤别离去 2024-12-02 05:20:03

实际上,我发布这个答案是为了防止其他人像我一样陷入困境。
穆罕默德·阿赫塔尔所说的非常有效,但是我找到了一个更简单的解决方案。

<asp:DropDownList ID="ddlAttorney" runat="server" DataSourceID="dsAttorney" DataValueField="AttorneyID" DataTextField="AttorneyNameWithCount" SelectedValue='<%# Bind("AttorneyID") %>'>

Bind("AttorneyID") 更改为 DataBinder.Eval (Container.DataItem, "AttorneyID")
它工作完美!
编辑:我的示例代码:

<asp:Content ID="Content3" ContentPlaceHolderID="BodyContent" runat="Server">
<asp:DetailsView ID="dv" runat="server" Height="50px" DataSourceID="ODS" DefaultMode="Insert"
    AutoGenerateRows="False" OnItemCommand="dv_ItemCommand" OnItemInserted="dv_ItemInserted"
    DataKeyNames="Id" OnItemUpdated="dv_ItemUpdated" CssClass="DetailsView" 
    >
    <Fields>
        <asp:TemplateField HeaderText="Page Name:">
            <ItemTemplate>
                <asp:Label ID="txtPageName" runat="server" Text="<%#Bind('PageName') %>" />
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="txtPageName" runat="server" Text="<%#Bind('PageName') %>" />
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Parent:">
            <ItemTemplate>
                <asp:Label ID="txtParentPageName" runat="server" Text='<%#Bind("ParentPageName") %>' />
            </ItemTemplate>
            <EditItemTemplate>
                <asp:DropDownList runat="server" ID="lstParentPage" DataSourceID="ParentPageODS"
                    AppendDataBoundItems="true" DataTextField="PageName" DataValueField="Id" SelectedValue="<%#Bind('ParentPage') %>"
                    AutoPostBack="True">
                    <asp:ListItem Text="-Root-" Value="" />
                </asp:DropDownList>
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="After...">
            <ItemTemplate>
                <asp:Label ID="txtPreviousPage" runat="server" Text='<%#Bind("PageOrder") %>' />
            </ItemTemplate>
            <EditItemTemplate>
                <asp:DropDownList runat="server" ID="lstPageOrder" AppendDataBoundItems="true" DataTextField="PageName" DataSourceID="PageOrderODS" DataValueField="PageOrder"  EnableViewState="False" SelectedValue='<%# DataBinder.Eval (Container.DataItem, "PageOrder") %>'>
                    <asp:ListItem Text="-First-" Value="" />
                </asp:DropDownList>
                <asp:ObjectDataSource ID="PageOrderODS" runat="server" SelectMethod="SelectByParent"
                    TypeName="SirM2X.Pages">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="lstParentPage" Name="ParentPage" PropertyName="SelectedValue" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Dummy Page?">
            <ItemTemplate>
                <asp:Label runat="server" ID="txtDummyPage" Text="<%#Bind('IsDummyText') %>" />
            </ItemTemplate>
            <EditItemTemplate>
                <asp:CheckBox ID="chkIsDummy" runat="server" Checked="<%#Bind('IsDummy') %>" />
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField ShowHeader="False">
            <EditItemTemplate>
                <asp:Button ID="btnUpdate" runat="server" CausesValidation="True" CommandName="Update"
                    Text="<%$Resources:Resources, Update %>" />
                 <asp:Button ID="btnCancel" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text="<%$Resources:Resources, Cancel %>" />
            </EditItemTemplate>
            <InsertItemTemplate>
                <asp:Button ID="btnInsert" runat="server" CausesValidation="True" CommandName="Insert"
                    Text="<%$Resources:Resources, Insert %>" />
                 <asp:Button ID="btnCancel" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text="<%$Resources:Resources, Cancel %>" />
            </InsertItemTemplate>
            <ItemTemplate>
                <asp:Button ID="btnEdit" runat="server" CausesValidation="False" CommandName="Edit"
                    Text="<%$Resources:Resources, Edit %>" />
            </ItemTemplate>
        </asp:TemplateField>
    </Fields>
</asp:DetailsView>
<asp:ObjectDataSource ID="ODS" runat="server" DeleteMethod="DeleteRow" InsertMethod="InsertRow"
    SelectMethod="SelectRow" TypeName="SirM2X.Pages" UpdateMethod="UpdateRow" OnInserting="ODS_Inserting"
    OnUpdating="ODS_Updating">
    <DeleteParameters>
        <asp:Parameter Name="Id" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="PageName" Type="String" />
        <asp:Parameter Name="CreatedBy" Type="String" />
        <asp:Parameter Name="ParentPage" Type="Int32" />
        <asp:Parameter Name="PageOrder" Type="Int32" />
        <asp:Parameter Name="IsDummy" Type="Boolean" />
    </InsertParameters>
    <SelectParameters>
        <asp:QueryStringParameter Name="Id" QueryStringField="ID" Type="Int32" />
    </SelectParameters>
    <UpdateParameters>
        <asp:Parameter Name="Id" Type="Int32" />
        <asp:Parameter Name="PageName" Type="String" />
        <asp:Parameter Name="ParentPage" Type="Int32" />
        <asp:Parameter Name="PageOrder" Type="Int32" />
        <asp:Parameter Name="IsDummy" Type="Boolean" />
        <asp:Parameter Name="DeleteState" Type="Boolean" />
    </UpdateParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ParentPageODS" runat="server" SelectMethod="SelectAll"
    TypeName="SirM2X.Pages"></asp:ObjectDataSource>

Actually I'm posting this answer in case anybody else got stuck like I did.
What Muhammad Akhtar said works perfectly, however I found a simpler solution.
In

<asp:DropDownList ID="ddlAttorney" runat="server" DataSourceID="dsAttorney" DataValueField="AttorneyID" DataTextField="AttorneyNameWithCount" SelectedValue='<%# Bind("AttorneyID") %>'>

change Bind("AttorneyID") to DataBinder.Eval (Container.DataItem, "AttorneyID")
It works perfectly!
EDIT: My sample code:

<asp:Content ID="Content3" ContentPlaceHolderID="BodyContent" runat="Server">
<asp:DetailsView ID="dv" runat="server" Height="50px" DataSourceID="ODS" DefaultMode="Insert"
    AutoGenerateRows="False" OnItemCommand="dv_ItemCommand" OnItemInserted="dv_ItemInserted"
    DataKeyNames="Id" OnItemUpdated="dv_ItemUpdated" CssClass="DetailsView" 
    >
    <Fields>
        <asp:TemplateField HeaderText="Page Name:">
            <ItemTemplate>
                <asp:Label ID="txtPageName" runat="server" Text="<%#Bind('PageName') %>" />
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="txtPageName" runat="server" Text="<%#Bind('PageName') %>" />
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Parent:">
            <ItemTemplate>
                <asp:Label ID="txtParentPageName" runat="server" Text='<%#Bind("ParentPageName") %>' />
            </ItemTemplate>
            <EditItemTemplate>
                <asp:DropDownList runat="server" ID="lstParentPage" DataSourceID="ParentPageODS"
                    AppendDataBoundItems="true" DataTextField="PageName" DataValueField="Id" SelectedValue="<%#Bind('ParentPage') %>"
                    AutoPostBack="True">
                    <asp:ListItem Text="-Root-" Value="" />
                </asp:DropDownList>
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="After...">
            <ItemTemplate>
                <asp:Label ID="txtPreviousPage" runat="server" Text='<%#Bind("PageOrder") %>' />
            </ItemTemplate>
            <EditItemTemplate>
                <asp:DropDownList runat="server" ID="lstPageOrder" AppendDataBoundItems="true" DataTextField="PageName" DataSourceID="PageOrderODS" DataValueField="PageOrder"  EnableViewState="False" SelectedValue='<%# DataBinder.Eval (Container.DataItem, "PageOrder") %>'>
                    <asp:ListItem Text="-First-" Value="" />
                </asp:DropDownList>
                <asp:ObjectDataSource ID="PageOrderODS" runat="server" SelectMethod="SelectByParent"
                    TypeName="SirM2X.Pages">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="lstParentPage" Name="ParentPage" PropertyName="SelectedValue" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Dummy Page?">
            <ItemTemplate>
                <asp:Label runat="server" ID="txtDummyPage" Text="<%#Bind('IsDummyText') %>" />
            </ItemTemplate>
            <EditItemTemplate>
                <asp:CheckBox ID="chkIsDummy" runat="server" Checked="<%#Bind('IsDummy') %>" />
            </EditItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField ShowHeader="False">
            <EditItemTemplate>
                <asp:Button ID="btnUpdate" runat="server" CausesValidation="True" CommandName="Update"
                    Text="<%$Resources:Resources, Update %>" />
                 <asp:Button ID="btnCancel" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text="<%$Resources:Resources, Cancel %>" />
            </EditItemTemplate>
            <InsertItemTemplate>
                <asp:Button ID="btnInsert" runat="server" CausesValidation="True" CommandName="Insert"
                    Text="<%$Resources:Resources, Insert %>" />
                 <asp:Button ID="btnCancel" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text="<%$Resources:Resources, Cancel %>" />
            </InsertItemTemplate>
            <ItemTemplate>
                <asp:Button ID="btnEdit" runat="server" CausesValidation="False" CommandName="Edit"
                    Text="<%$Resources:Resources, Edit %>" />
            </ItemTemplate>
        </asp:TemplateField>
    </Fields>
</asp:DetailsView>
<asp:ObjectDataSource ID="ODS" runat="server" DeleteMethod="DeleteRow" InsertMethod="InsertRow"
    SelectMethod="SelectRow" TypeName="SirM2X.Pages" UpdateMethod="UpdateRow" OnInserting="ODS_Inserting"
    OnUpdating="ODS_Updating">
    <DeleteParameters>
        <asp:Parameter Name="Id" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="PageName" Type="String" />
        <asp:Parameter Name="CreatedBy" Type="String" />
        <asp:Parameter Name="ParentPage" Type="Int32" />
        <asp:Parameter Name="PageOrder" Type="Int32" />
        <asp:Parameter Name="IsDummy" Type="Boolean" />
    </InsertParameters>
    <SelectParameters>
        <asp:QueryStringParameter Name="Id" QueryStringField="ID" Type="Int32" />
    </SelectParameters>
    <UpdateParameters>
        <asp:Parameter Name="Id" Type="Int32" />
        <asp:Parameter Name="PageName" Type="String" />
        <asp:Parameter Name="ParentPage" Type="Int32" />
        <asp:Parameter Name="PageOrder" Type="Int32" />
        <asp:Parameter Name="IsDummy" Type="Boolean" />
        <asp:Parameter Name="DeleteState" Type="Boolean" />
    </UpdateParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ParentPageODS" runat="server" SelectMethod="SelectAll"
    TypeName="SirM2X.Pages"></asp:ObjectDataSource>

阳光的暖冬 2024-12-02 05:20:03

这可能来得有点晚,但迟到总比不到好:

Protected Sub DetailsView1_ItemUpdating(sender As Object, e As System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles DetailsView1.ItemUpdating
  e.NewValues("AtendeeSubType") = DirectCast(DirectCast(sender, DetailsView).FindControl("dropdownlist3"), DropDownList).SelectedValue
End Sub

我针对详细信息视图的 ItemUpdating 事件测试了它,但我认为它适用于表单视图,只需切换您需要的部分,它就会工作。

编辑:您可以检查此参考:
http://msdn.microsoft.com /en-us/library/system.web.ui.webcontrols.detailsview.itemupdating.aspx

This may come a little bit late but better late than never:

Protected Sub DetailsView1_ItemUpdating(sender As Object, e As System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles DetailsView1.ItemUpdating
  e.NewValues("AtendeeSubType") = DirectCast(DirectCast(sender, DetailsView).FindControl("dropdownlist3"), DropDownList).SelectedValue
End Sub

I tested this for the event ItemUpdating of a details view but I think it will work for a formview, just switch the parts you need and it will work.

Edit: You can check this reference:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.detailsview.itemupdating.aspx

冷情 2024-12-02 05:20:03

我是这样做的......

<asp:SqlDataSource ID="sqldsDDPlant" runat="server" ConnectionString="<%$ ConnectionStrings:SeedTrackerConnectionString %>" 
    SelectCommand="SELECT * FROM [Plant] ORDER BY [Plant]"></asp:SqlDataSource>

<asp:SqlDataSource ID="sqldsDDType" runat="server" ConnectionString="<%$ ConnectionStrings:SeedTrackerConnectionString %>" 
    SelectCommand="SELECT * FROM [Type] ORDER BY [Type]" FilterExpression="PLID = '{0}'">
        <FilterParameters>
            <asp:ControlParameter Name="plantParam" ControlID="DVSeedTracker$ddPlant" PropertyName="SelectedValue" />
        </FilterParameters>  
</asp:SqlDataSource>

        <asp:TemplateField HeaderText="Plant">
            <InsertItemTemplate>
                <asp:DropDownList ID="ddPlant" runat="server" AutoPostBack="true" SelectedValue='<%# Bind("PLID") %>'
                 DataSourceID="sqldsDDPlant"  DataTextField="Plant" DataValueField="PLID" AppendDataBoundItems="True">
                    <asp:ListItem></asp:ListItem>
                </asp:DropDownList>
                 <asp:RequiredFieldValidator
                    id="RequiredFieldValidator2"
                    runat="server"
                    ControlToValidate="ddPlant"
                    Display="Static"
                    ErrorMessage="*Required" CssClass="RequiredField" />                
            </InsertItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Type">
            <InsertItemTemplate>
                <asp:DropDownList ID="ddType" runat="server"
                DataSourceID="sqldsDDType"  DataTextField="Type" DataValueField="TYPID" AppendDataBoundItems="False">
                    <asp:ListItem></asp:ListItem>
                </asp:DropDownList>
                    <asp:RequiredFieldValidator
                    id="RequiredFieldValidator3"
                    runat="server"
                    ControlToValidate="ddType"
                    Display="Static"
                    ErrorMessage="*Required" CssClass="RequiredField" />                                   
            </InsertItemTemplate>
        </asp:TemplateField>

Here is how I did it...

<asp:SqlDataSource ID="sqldsDDPlant" runat="server" ConnectionString="<%$ ConnectionStrings:SeedTrackerConnectionString %>" 
    SelectCommand="SELECT * FROM [Plant] ORDER BY [Plant]"></asp:SqlDataSource>

<asp:SqlDataSource ID="sqldsDDType" runat="server" ConnectionString="<%$ ConnectionStrings:SeedTrackerConnectionString %>" 
    SelectCommand="SELECT * FROM [Type] ORDER BY [Type]" FilterExpression="PLID = '{0}'">
        <FilterParameters>
            <asp:ControlParameter Name="plantParam" ControlID="DVSeedTracker$ddPlant" PropertyName="SelectedValue" />
        </FilterParameters>  
</asp:SqlDataSource>

        <asp:TemplateField HeaderText="Plant">
            <InsertItemTemplate>
                <asp:DropDownList ID="ddPlant" runat="server" AutoPostBack="true" SelectedValue='<%# Bind("PLID") %>'
                 DataSourceID="sqldsDDPlant"  DataTextField="Plant" DataValueField="PLID" AppendDataBoundItems="True">
                    <asp:ListItem></asp:ListItem>
                </asp:DropDownList>
                 <asp:RequiredFieldValidator
                    id="RequiredFieldValidator2"
                    runat="server"
                    ControlToValidate="ddPlant"
                    Display="Static"
                    ErrorMessage="*Required" CssClass="RequiredField" />                
            </InsertItemTemplate>
        </asp:TemplateField>

        <asp:TemplateField HeaderText="Type">
            <InsertItemTemplate>
                <asp:DropDownList ID="ddType" runat="server"
                DataSourceID="sqldsDDType"  DataTextField="Type" DataValueField="TYPID" AppendDataBoundItems="False">
                    <asp:ListItem></asp:ListItem>
                </asp:DropDownList>
                    <asp:RequiredFieldValidator
                    id="RequiredFieldValidator3"
                    runat="server"
                    ControlToValidate="ddType"
                    Display="Static"
                    ErrorMessage="*Required" CssClass="RequiredField" />                                   
            </InsertItemTemplate>
        </asp:TemplateField>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文