Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 基于列中值的数据绑定中继器_C#_Asp.net_Sql Server - Fatal编程技术网

C# 基于列中值的数据绑定中继器

C# 基于列中值的数据绑定中继器,c#,asp.net,sql-server,C#,Asp.net,Sql Server,我正在使用MicrosoftSQLServer2005&将下拉列表数据绑定到一个包含一些记录的表中。在下拉列表的选定索引更改中,我希望我的中继器仅重新数据绑定显示与下拉列表中选定值具有相同ID的记录 这是我的下拉列表: <asp:DropDownList ID="ddlViewLabel" runat="server" Width="280px" DataSourceID="sdsLabels" DataTextField="LabelName" DataValueField="Lab

我正在使用MicrosoftSQLServer2005&将下拉列表数据绑定到一个包含一些记录的表中。在下拉列表的选定索引更改中,我希望我的中继器仅重新数据绑定显示与下拉列表中选定值具有相同ID的记录

这是我的下拉列表:

<asp:DropDownList ID="ddlViewLabel" runat="server" Width="280px" 
 DataSourceID="sdsLabels" DataTextField="LabelName" DataValueField="LabelID" 
 onselectedindexchanged="ddlViewLabel_SelectedIndexChanged">
</asp:DropDownList>

这是我的中继器:

<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>

以下是我的两个数据源:

    <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>


我在哪里输入逻辑来过滤中继器,使其不显示具有正确“LabelID”的“文档”?

您需要为dropdownlist上定义的ddlViewLabel\u SelectedIndexChanged方法编写一些代码

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

}

你们在TBL文档中有外键标签吗?对不起,穆罕默德,遗漏了我的部分问题。请看我的零钱。我有一个“链接”表,它用正确的标签链接每个文档。如果行数不太大,只要dropdownlist发生更改,您就可以使用jQuery或JavaScript显示/隐藏行。我如何将它们附加到repeater?repeater.DataSource=