Here is a simple example.

ASPX

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Test._Default" %>

<%@ Register Assembly="DevExpress.Web.v12.2, Version=12.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>

<%@ Register Assembly="DevExpress.Web.v12.2, Version=12.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form" runat="server">
<script language="javascript" type="text/javascript">
function OnGetSelectedFieldValues(selectedValues) {
alert(selectedValues);
}
</script>
<dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" DataSourceID="masterDataSource"
KeyFieldName="ID" Width="100%">
<Columns>
<dx:GridViewDataColumn FieldName="Name" Caption="名称" />
</Columns>
<Templates>
<DetailRow>
<dx:ASPxGridView ID="detailGrid" runat="server" KeyFieldName="ID"
Width="100%" ClientInstanceName="dgdv" OnInit="detailGrid_Init">
<Columns>
<dx:GridViewCommandColumn ShowSelectCheckbox="True">
<HeaderTemplate>
<dx:ASPxCheckBox ID="SelectAllCheckBox" runat="server" ToolTip="Select/Unselect all rows on the page"
ClientSideEvents-CheckedChanged="function(s, e) { dgdv.SelectAllRowsOnPage(s.GetChecked()); }" />
</HeaderTemplate>
<HeaderStyle HorizontalAlign="Center" />
</dx:GridViewCommandColumn>
<dx:GridViewDataColumn FieldName="Name" Caption="名称" />
</Columns>
<SettingsBehavior AllowSelectByRowClick="true" />
</dx:ASPxGridView>
</DetailRow>
</Templates>
<SettingsDetail ShowDetailRow="true" AllowOnlyOneMasterRowExpanded="true" />
</dx:ASPxGridView>
<dx:ASPxButton ID="btnTest" runat="server" Text="Test">
<ClientSideEvents Click="function(s, e){
dgdv.GetSelectedFieldValues('ID', OnGetSelectedFieldValues);
e.processOnServer = false;
}" />
</dx:ASPxButton>
<asp:SqlDataSource
ID="masterDataSource"
runat="server"
DataSourceMode="DataReader"
ConnectionString="<%$ ConnectionStrings:TestConn%>"
SelectCommand="SELECT * FROM Line"></asp:SqlDataSource>
</form>
</body>
</html>

CS

using DevExpress.Web.ASPxEditors;
using DevExpress.Web.ASPxGridView;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; namespace Test
{
public partial class _Default : System.Web.UI.Page
{
protected void detailGrid_Init(object sender, EventArgs e)
{
ASPxGridView dgrid = sender as ASPxGridView;
if (dgrid == null) return; var dataFileId = (int)(sender as ASPxGridView).GetMasterRowFieldValues("ID");
DataTable table = new DataTable();
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["TestConn"].ConnectionString);
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = string.Format("select * from Main where LineID={0}", dataFileId);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(table);
conn.Close();
dgrid.DataSource = table;
dgrid.DataBind();
}
}
}

Dev GridView-Bind Detail Grid during runtime的更多相关文章

  1. Dev gridView中设置自适应列宽和日期显示格式、金额的显示格式

    在Dev GridView控件中,数据库中表数据日期都是长日期格式(yyyy-MM-dd HH:mm:ss),但显示在控件变成短日期格式(yyyy-MM-dd),金额显示要显示精确的数值, 比如80. ...

  2. dev gridview指定单元格cell获取坐标

    DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo Info2 = gvQueryResult.GetViewInfo() as DevExpre ...

  3. DEV GridView嵌套

    近来的DEV搞更多.试图寻找专业点的程序做,对这样一个小小的研究. 本篇是多么真实,现在的记录,可以通过点击这条线的子表的内容相关联的行中打开的列表.的影响,如下面的: 以下是实现过程: 1.设计器里 ...

  4. Winform 中DataGridView、dev Gridview控件添加行标题

    有很多种方法. 1.可以在DataGridView控件中的RowStateChanged事件改变行标题单元格的值(Row.HeaderCell.Value) /// <summary> / ...

  5. Dev GridView行拖拽

    http://blog.csdn.net/keyrainie/article/details/8513802 http://www.cnblogs.com/qq4004229/archive/2012 ...

  6. c#dev gridview 设置隔行换色等

    1:禁止gridview编辑 2:隔行换色 介绍一些常用的gridcontrol设置. 1.设置隔行变色.首先设置显示隔行变色,步骤:OptionsView-->EnableAppearance ...

  7. GridView Bind 短日期 格式

    ASP.NET的GridView控件的编辑模板中,需要绑定数据库中的某个字段,如<%# Bind("startTime","{0:d}") %> 在 ...

  8. Dev GridView 属性说明

    说明  Options  OptionsBehavior 视图的行为选项 AllowIncrementalSearch 允许用户通过输入想得到的列值来定位行 AllowPartialRedrawOnS ...

  9. dev gridview拖拽数据移动

    设置属性gridView1.OptionsSelection.EnableAppearanceFocusedCell = false; //确保选定行的背景色一样. private BindingLi ...

随机推荐

  1. Codeforces 1091 Good Bye 2018

    占个坑先,希望不要掉的太惨了吧,不要掉到上一次之前的rating upt:flag竟然没到,开心. A - New Year and the Christmas Ornament 好像没什么可说的. ...

  2. json获取元素数量

    var keleyijson={"plug1":"myslider","plug2":"zonemenu"} funct ...

  3. Faster-RCNN-TensorFlow-Python3.5 在Ubuntu16.04下的配置方法

    目录 Faster-RCNN-TensorFlow-Python3.5 在Ubuntu16.04下的配置方法 安装过程 1. 深度学习环境Tensorflow的安装 2. 安装python包 3.   ...

  4. 【TCP/IP协议 卷一:协议】第三章 IP:网际协议

    3.1 引言 unreliable不可靠的意思是它并不能保证IP数据报能成功的到达目的地.IP只提供尽力而为的传输服务. conectionless无连接的意思是IP并不维护任何关于后续数据报的状态信 ...

  5. Codeforces Beta Round #94 div 2 B

    B. Students and Shoelaces time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  6. ubuntu 14.04 安装 gflags

    1.下载 git clone https://github.com/gflags/gflags 2.编译 进入源码目录(即gflags文件夹) cmake . make -j 24 sudo make ...

  7. QString 编码转换

    参考网址:http://blog.csdn.net/lfw19891101/article/details/6641785 (网页保存于:百度云CodeSkill33 --> 全部文件 > ...

  8. VC6_导入lib库

    http://www.cnblogs.com/webcyz/p/3525166.html 2. 导入lib库.导入的方法很多方法1) 直接用project>add to project>f ...

  9. English trip -- VC(情景课)2 D Reading

    Xu言: 业精于勤,荒于嬉:行成于思,毁于随 Before you read 阅读准备 Talk about the picture, what do you see?看图说话,你看到了什么? Lis ...

  10. 『cs231n』作业1选讲_通过代码理解KNN&交叉验证&SVM

    通过K近邻算法探究numpy向量运算提速 茴香豆的“茴”字有... ... 使用三种计算图片距离的方式实现K近邻算法: 1.最为基础的双循环 2.利用numpy的broadca机制实现单循环 3.利用 ...