Skip to content

Instantly share code, notes, and snippets.

@masaru-b-cl
Last active December 11, 2015 03:08
Show Gist options
  • Select an option

  • Save masaru-b-cl/4535511 to your computer and use it in GitHub Desktop.

Select an option

Save masaru-b-cl/4535511 to your computer and use it in GitHub Desktop.
NestedRepeaterWebApplication
bin/
obj/
*.suo
*.user
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// アセンブリに関する一般情報は、以下の属性セットによって
// 制御されます。 アセンブリに関連付けられている情報を変更するには、
// これらの属性値を変更してください。
[assembly: AssemblyTitle("NestedRepeaterWebApplication")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NestedRepeaterWebApplication")]
[assembly: AssemblyCopyright("Copyright © 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから
// 見えなくなります。 COM からこのアセンブリ内の型にアクセスする必要がある場合は、
// その型の ComVisible 属性を true に設定してください。
[assembly: ComVisible(false)]
// このプロジェクトが COM に公開される場合、次の GUID が typelib の ID になります
[assembly: Guid("ea922244-2403-4ae1-bb45-0962091667be")]
// アセンブリのバージョン情報は、以下の 4 つの値で構成されます:
//
// メジャー バージョン
// マイナー バージョン
// ビルド番号
// リビジョン
//
// すべての値を指定するか、次のように '*' を使ってリビジョンおよびビルド番号を
// 既定値にすることができます。
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="NestedRepeaterWebApplication.Default" %>
<!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="form1" runat="server">
<div>
<asp:Repeater ID="ParentRepeater" runat="server"
DataSourceID="GokiObjectDataSource"
onitemdatabound="ParentRepeater_ItemDataBound">
<ItemTemplate>
<div>
GokiNo : <%# Eval("GokiNo") %>
<asp:Repeater ID="ChildRepeater" runat="server">
<ItemTemplate>
<table border="1">
<tr>
<td>Code</td>
<td><%# Eval("Code") %></td>
<td>Name</td>
<td><%# Eval("Name")%></td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
<SeparatorTemplate>
<hr />
</SeparatorTemplate>
</asp:Repeater>
</div>
<asp:ObjectDataSource ID="GokiObjectDataSource" runat="server"
SelectMethod="GetData" TypeName="NestedRepeaterWebApplication.DummyDao">
</asp:ObjectDataSource>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace NestedRepeaterWebApplication
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
/// <summary>
/// 号機毎にデータバインドされた時のイベント
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ParentRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
// 通常の行と切り替え行のときのみ
ListItemType itemType = e.Item.ItemType;
if (itemType == ListItemType.Item || itemType == ListItemType.AlternatingItem)
{
// 号機データを取得し
var goki = e.Item.DataItem as Goki;
// 子リピーターを取得し
var childRepeater = e.Item.FindControl("ChildRepeater") as Repeater;
// 号機の中のコレクションを子リピーターにデータバインド
childRepeater.DataSource = goki.Entities;
childRepeater.DataBind();
}
}
}
}
//------------------------------------------------------------------------------
// <自動生成>
// このコードはツールによって生成されました。
//
// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
// コードが再生成されるときに損失したりします。
// </自動生成>
//------------------------------------------------------------------------------
namespace NestedRepeaterWebApplication {
public partial class Default {
/// <summary>
/// form1 コントロール。
/// </summary>
/// <remarks>
/// 自動生成されたフィールド。
/// 変更するには、フィールドの宣言をデザイナー ファイルから分離コード ファイルに移動します。
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// ParentRepeater コントロール。
/// </summary>
/// <remarks>
/// 自動生成されたフィールド。
/// 変更するには、フィールドの宣言をデザイナー ファイルから分離コード ファイルに移動します。
/// </remarks>
protected global::System.Web.UI.WebControls.Repeater ParentRepeater;
/// <summary>
/// GokiObjectDataSource コントロール。
/// </summary>
/// <remarks>
/// 自動生成されたフィールド。
/// 変更するには、フィールドの宣言をデザイナー ファイルから分離コード ファイルに移動します。
/// </remarks>
protected global::System.Web.UI.WebControls.ObjectDataSource GokiObjectDataSource;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace NestedRepeaterWebApplication
{
public class DummyDao
{
public List<Goki> GetData()
{
return new[]{
new Goki {
GokiNo = "1",
Entities = new List<Entity>() {
new Entity { Code = "101", Name = "名前101"},
new Entity { Code = "102", Name = "名前102"},
new Entity { Code = "103", Name = "名前103"},
}
},
new Goki {
GokiNo = "2",
Entities = new List<Entity>() {
new Entity { Code = "201", Name = "名前201"},
new Entity { Code = "202", Name = "名前202"},
new Entity { Code = "203", Name = "名前203"},
}
},
}.ToList();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace NestedRepeaterWebApplication
{
public class Entity
{
public string Code { get; set; }
public string Name { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace NestedRepeaterWebApplication
{
public class Goki
{
public string GokiNo { get; set; }
public List<Entity> Entities { get; set; }
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{F19D4017-EE73-4963-8061-548A3ED01632}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NestedRepeaterWebApplication</RootNamespace>
<AssemblyName>NestedRepeaterWebApplication</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
</ItemGroup>
<ItemGroup>
<Content Include="Default.aspx" />
<Content Include="Web.config" />
<Content Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</Content>
<Content Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
</Content>
</ItemGroup>
<ItemGroup>
<Compile Include="Default.aspx.cs">
<DependentUpon>Default.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Default.aspx.designer.cs">
<DependentUpon>Default.aspx</DependentUpon>
</Compile>
<Compile Include="DummyDao.cs" />
<Compile Include="Entity.cs" />
<Compile Include="Goki.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>38057</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:37500/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NestedRepeaterWebApplication", "NestedRepeaterWebApplication.csproj", "{F19D4017-EE73-4963-8061-548A3ED01632}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F19D4017-EE73-4963-8061-548A3ED01632}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F19D4017-EE73-4963-8061-548A3ED01632}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F19D4017-EE73-4963-8061-548A3ED01632}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F19D4017-EE73-4963-8061-548A3ED01632}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<!--
ASP.NET アプリケーションの構成方法の詳細については、
http://go.microsoft.com/fwlink/?LinkId=169433 を参照してください
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<!-- web.config 変換の使用方法の詳細については、http://go.microsoft.com/fwlink/?LinkId=125889 を参照してください -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
以下の例では、"Match" ロケーターで "MyDB" という値の "name" 属性が見つかった
場合にのみ、"SetAttributes" 変換により "connectionString" の値が変更され、
"ReleaseSQLServer" が使用されるようになります。
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<!--
以下の例では、"Replace" 変換により web.config ファイルの
<customErrors> セクション全体が置換されます。
<system.web> ノードには customErrors セクションが 1 つしかないため、
"xdt:Locator" 属性を使用する必要はありません。
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<!-- web.config 変換の使用方法の詳細については、http://go.microsoft.com/fwlink/?LinkId=125889 を参照してください -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
以下の例では、"Match" ロケーターで "MyDB" という値の "name" 属性が見つかった
場合にのみ、"SetAttributes" 変換により "connectionString" の値が変更され、
"ReleaseSQLServer" が使用されるようになります。
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
以下の例では、"Replace" 変換により web.config ファイルの
<customErrors> セクション全体が置換されます。
<system.web> ノードには customErrors セクションが 1 つしかないため、
"xdt:Locator" 属性を使用する必要はありません。
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment