2011-08-18 2 views
0

Microsoft SQL Server 2005를 사용하고 있습니다. &에는 몇 개의 레코드가있는 테이블에 드롭 다운 목록 데이터가 있습니다. 드롭 다운 목록의 선택된 인덱스 변경에서 드롭 다운 목록에서 선택한 값과 동일한 ID를 가진 레코드 만 리퍼터가 다시 데이터 바인딩하도록합니다. I가 논리를 입력 할Databind 리피터 열의 값을 기반으로

<asp:SqlDataSource ID="sdsDocuments" runat="server" ConnectionString="<%$ ConnectionStrings:blcDocumentationConnectionString %>" 
      SelectCommand="SELECT [DocumentID], [DocumentTitle], [DocumentBody], [ModifiedDate], [CreatedDate] FROM [tblDocument]"> 
     </asp:SqlDataSource> 
    <asp:SqlDataSource ID="sdsLabels" runat="server" ConnectionString="<%$ ConnectionStrings:blcDocumentationConnectionString %>" 
      SelectCommand="SELECT [LabelID], [LabelName] FROM [tblLabel]"></asp:SqlDataSource> 
<asp:SqlDataSource ID="sdsLink" runat="server" 
    ConnectionString="<%$ ConnectionStrings:blcDocumentationConnectionString %>" 
    SelectCommand="SELECT [LabelID], [DocumentID], [LinkID] FROM [tblLink]"></asp:SqlDataSource> 

: 여기

<asp:Repeater ID="rptDocuments" runat="server" OnItemCommand="viewDocument_ItemCommand" 
DataSourceID="sdsDocuments"> 
<HeaderTemplate> 
</HeaderTemplate> 
<ItemTemplate> 
    <div class="nav-rpt"> 
    <asp:LinkButton ID="lnkDocumentTitle" Text='<%# Bind("DocumentTitle") %>' runat="server" 
          CommandArgument='<%# Eval("DocumentID") %>' CssClass="nav-rpt-btn"></asp:LinkButton> 
    <img src="Images/ARROW.png" style="float: right" /> 
    </div> 
</ItemTemplate> 
<SeparatorTemplate> 
    <div style="border-top-style: solid; border-top-width: 1px; border-top-color: #C0C0C0;"> 
    </div> 
</SeparatorTemplate> 
<FooterTemplate> 
    <div style="border-top-style: solid; border-top-width: 1px; border-top-color: #C0C0C0;"> 
    </div> 
</FooterTemplate> 
</asp:Repeater> 

제 2 데이터 소스입니다 : 여기
<asp:DropDownList ID="ddlViewLabel" runat="server" Width="280px" 
DataSourceID="sdsLabels" DataTextField="LabelName" DataValueField="LabelID" 
onselectedindexchanged="ddlViewLabel_SelectedIndexChanged"> 
</asp:DropDownList> 

내 중계기 : 여기

다운 목록 내 드롭입니다 올바른 'LabelID'로 'Documents'를 표시하는 중계기를 필터링 하시겠습니까?

+0

당신이 외부 키로 tblDocuments에 labelId 한 않는 드롭 다운리스트에 정의 된 ddlViewLabel_SelectedIndexChanged 방법에 대한 몇 가지 코드를 작성해야합니까? –

+0

미안 해요 무함마드, 제 질문의 일부를 생략했습니다. @ 변경 사항을보십시오. 각 문서를 올바른 레이블로 연결하는 '링크'테이블이 있습니다. – bluetickk

+0

행 수가 너무 크지 않은 경우 드롭 다운 목록이 변경 될 때마다 jQuery 또는 JavaScript로 행을 표시하거나 숨길 수 있습니다. – Narnian

답변

0

당신은

protected void ddlViewLabel_SelectedIndexChanged(object sender, EventArgs e) 
{ 
DropDownList d = (DropDownList)sender; 

// psudeo code from here on out 
// get the DropDownList selected index 
// create the new SQL statement 
// either create a new SQlDataSource or SqlCommand/SqlConnection objects, set the sql, attach them to the repeater, bind 

} 
+0

리피터에 연결하려면 어떻게해야합니까? – bluetickk

+0

repeater.DataSource = Wil

관련 문제