• ASPxGridView中如何对主从表绑定数据


    注:在从表的aspxgridview中的(OnDataBinding()事件中绑定数据)-----代码如下

    //绑定属性值表
    protected void grid2_sonTable_DataBinding(object sender, EventArgs e)
    {
    ASPxGridView songrid = (ASPxGridView)sender; //实例化从表表
    object _faterid = songrid.GetMasterRowKeyValue(); //获取主表行id(模板grid中的id值)
    DataTable dt = new DataTable();
    dt = goodsmanagebll.Get_GetAttributeValueListByAttrId(int.Parse(_faterid.ToString())).Tables[0];
    songrid.DataSource = dt;

    }

    gridview主从表效果图:

    gridview主从表效果图主从表绑定代码图:主从表绑定代码图

    //主从表前端代码

    <dx:ASPxGridView ID="ASPxGridView2" ClientInstanceName="ASPxGridView2" runat="server" Width="55%" AutoGenerateColumns="False" KeyFieldName="ATTRID" Theme="Mulberry"
    OnHtmlDataCellPrepared="ASPxGridView2_HtmlDataCellPrepared" OnHtmlEditFormCreated="ASPxGridView2_HtmlEditFormCreated" OnRowDeleting="ASPxGridView2_RowDeleting"
    OnRowUpdating="ASPxGridView2_RowUpdating" OnRowInserting="ASPxGridView2_RowInserting">
    <ClientSideEvents EndCallback="grid2_EndCallback" />
    <SettingsText EmptyDataRow="暂无数据" CommandEdit="修改" />
    <SettingsEditing Mode="PopupEditForm"></SettingsEditing>
    <SettingsDetail ShowDetailRow="True" AllowOnlyOneMasterRowExpanded="true" />
    <Styles>
    <%--<AlternatingRow Enabled="True" />
    <Header HorizontalAlign="Center" />
    <CommandColumn Spacing="10px" Wrap="False" />--%>
    <%--<Header BackColor="#b5b5ff" ForeColor="#000000"></Header>--%>
    <Cell HorizontalAlign="Center"></Cell>
    <Table CssClass="tw-dataTable"></Table>
    <Header CssClass="tw-dtheader" HorizontalAlign="Center"></Header>
    <CommandColumn CssClass="tw-commandColumn"></CommandColumn>
    <CommandColumnItem CssClass="tw-commandColumnBtn"></CommandColumnItem>
    <FocusedRow CssClass="tw-focusRow"></FocusedRow>
    </Styles>
    <SettingsPager PageSize="10" />
    <SettingsBehavior AllowFocusedRow="True" />
    <SettingsEditing Mode="PopupEditForm"></SettingsEditing>
    <Settings GridLines="Horizontal" />
    <SettingsPopup>
    <EditForm Modal="true" HorizontalAlign="WindowCenter" VerticalAlign="WindowCenter" />
    </SettingsPopup>
    <SettingsBehavior ConfirmDelete="true" />
    <SettingsText ConfirmDelete="确定要删除吗?" />
    <SettingsDetail ShowDetailRow="true" />
    <Columns>

    <dx:GridViewDataColumn Caption="编号" VisibleIndex="1" FieldName="ATTRID" Width="2%"></dx:GridViewDataColumn>
    <dx:GridViewDataColumn Caption="属性名称" VisibleIndex="2" FieldName="ATTRNAME" Width="20%"></dx:GridViewDataColumn>
    <dx:GridViewDataComboBoxColumn Caption="属性分组" VisibleIndex="3" FieldName="ATTRGROUPID" Width="20%">
    <PropertiesComboBox TextField="ATTRGROUPNAME" ValueField="ATTRGROUPID" ValueType="System.Int32"></PropertiesComboBox>
    </dx:GridViewDataComboBoxColumn>
    <dx:GridViewDataComboBoxColumn Caption="展示类型" VisibleIndex="4" FieldName="SHOWTYPE" Width="3%">
    <PropertiesComboBox>
    <Items>
    <dx:ListEditItem Value="0" Text="文字" />
    <dx:ListEditItem Value="1" Text="图片" />
    </Items>
    </PropertiesComboBox>
    </dx:GridViewDataComboBoxColumn>
    <dx:GridViewDataComboBoxColumn Caption="筛选属性" VisibleIndex="5" FieldName="ISFILTER" Width="3%">
    <PropertiesComboBox>
    <Items>
    <dx:ListEditItem Value="0" Text="否" />
    <dx:ListEditItem Value="1" Text="是" />
    </Items>
    </PropertiesComboBox>
    </dx:GridViewDataComboBoxColumn>
    <dx:GridViewDataColumn Caption="排序" VisibleIndex="6" FieldName="DISPLAYORDER" Width="2%"></dx:GridViewDataColumn>
    <dx:GridViewCommandColumn Caption="通用价操作" ShowEditButton="True" ShowNewButtonInHeader="true" ShowDeleteButton="true" ShowInCustomizationForm="True" VisibleIndex="7" Width="8%">
    <EditButton Text="修 改"></EditButton>
    </dx:GridViewCommandColumn>
    </Columns>

    <Templates>
    <%--从表--%>
    <DetailRow>
    <p style="color:#b7245f;font-size:13px;font-weight:bold;">属性值列表</p>

    <dx:ASPxGridView ID="grid2_sonTable" ClientInstanceName="grid2_sonTable" runat="server" Width="22%" AutoGenerateColumns="False" KeyFieldName="ATTRVALUEID" Theme="Mulberry"
    OnDataBinding="grid2_sonTable_DataBinding" OnRowUpdating="grid2_sonTable_RowUpdating" OnRowDeleting="grid2_sonTable_RowDeleting" OnRowInserting="grid2_sonTable_RowInserting" OnHtmlEditFormCreated="grid2_sonTable_HtmlEditFormCreated">
    <ClientSideEvents EndCallback="grid2_sonTable_EndCallback" />
    <SettingsText EmptyDataRow="暂无数据" CommandEdit="修改" />
    <SettingsEditing Mode="PopupEditForm"></SettingsEditing>

    <Styles>
    <AlternatingRow Enabled="True" />
    <Header HorizontalAlign="Center" />
    <CommandColumn Spacing="10px" Wrap="False" />
    <%-- <Header BackColor="#b5b5ff" ForeColor="#000000"></Header>--%>

    <%--<Table CssClass="tw-dataTable"></Table>
    <Header CssClass="tw-dtheader" HorizontalAlign="Center"></Header>--%>
    <CommandColumn CssClass="tw-commandColumn"></CommandColumn>
    <CommandColumnItem CssClass="tw-commandColumnBtn"></CommandColumnItem>
    <FocusedRow CssClass="tw-focusRow"></FocusedRow>
    <Cell HorizontalAlign="Center"></Cell>
    </Styles>
    <SettingsBehavior ConfirmDelete="true" />
    <SettingsText ConfirmDelete="确定要删除吗?" />
    <SettingsPager PageSize="10" />
    <SettingsBehavior AllowFocusedRow="True" />
    <SettingsEditing Mode="PopupEditForm"></SettingsEditing>
    <Settings GridLines="Horizontal" />
    <SettingsPopup>
    <EditForm Modal="true" HorizontalAlign="WindowCenter" VerticalAlign="WindowCenter" />
    </SettingsPopup>
    <Columns>
    <dx:GridViewDataColumn Caption="编号" VisibleIndex="1" FieldName="ATTRVALUEID" Width="2%"></dx:GridViewDataColumn>
    <dx:GridViewDataColumn Caption="属性值" VisibleIndex="2" FieldName="ATTRVALUE" Width="5%"></dx:GridViewDataColumn>
    <%-- <dx:GridViewDataColumn Caption="所属属性" VisibleIndex="3" FieldName="ATTRNAME"></dx:GridViewDataColumn>--%>
    <dx:GridViewDataColumn Caption="排序" VisibleIndex="4" FieldName="ATTRVALUEDISPLAYORDER" Width="2%"></dx:GridViewDataColumn>
    <dx:GridViewDataColumn Caption="属性id" VisibleIndex="6" FieldName="ATTRID" Visible="false"></dx:GridViewDataColumn>
    <dx:GridViewDataColumn Caption="属性分组id" VisibleIndex="6" FieldName="ATTRGROUPID" Visible="false"></dx:GridViewDataColumn>
    <dx:GridViewDataColumn Caption="属性名称" VisibleIndex="2" FieldName="ATTRNAME" Width="5%"></dx:GridViewDataColumn>
    <dx:GridViewCommandColumn Caption="通用价操作" ShowEditButton="True" ShowDeleteButton="true" ShowNewButtonInHeader="true" ShowInCustomizationForm="True" VisibleIndex="5" Width="8%">
    <EditButton Text="修改"></EditButton>
    </dx:GridViewCommandColumn>
    </Columns>

    </dx:ASPxGridView>
    </DetailRow>

    </Templates>
    </dx:ASPxGridView>

    我还是会相信,星星会说话,石头会开花,穿过夏天的栅栏和冬天的风雪过后,你终会抵达。
  • 相关阅读:
    NSInvalidArgumentException', reason: '[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: WebKitLocalStorageDatabasePathPreferenc
    Mac下Android开发环境的搭建
    Xcode 4.4 的新特性 | LLVM 4.0 的新语法
    UIButton设置 textAlignment 属性的方法
    ipa包中图片进行了Compress之后的主要处理和作用
    苹果开发者证书的申请流程 Apple ID for IDP..
    systemtap perf 火焰图
    pg_blocking pg_monitor (转) postgresql表死锁问题的排查方式 阻塞分析 慢SQL
    知识广度 vs 知识深度
    火焰图入门
  • 原文地址:https://www.cnblogs.com/dfxyw/p/5080084.html
Copyright © 2020-2023  润新知