使用Web用户控件

时间:2014-10-14 21:37:25

标签: asp.net user-controls

我有一个Web用户控件,它包含一个RadGrid和一个SqlDataSource,看起来像这样(至少部分)

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="ProductionMatching.ascx.vb" Inherits="ProductionMatching" %>
<telerik:RadGrid ID="RadGrid2" DataSourceID="SqlNBTA" runat="server" GridLines="None"
    AllowPaging="True" CellSpacing="0">
    <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="True" Position="TopAndBottom">
    </PagerStyle>
    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
    </HeaderContextMenu>
    <MasterTableView ShowHeader="false" TableLayout="Fixed" PageSize="250" PagerStyle-AlwaysVisible="True"
        PagerStyle-Position="TopAndBottom" AutoGenerateColumns="False">
        <ItemTemplate>
            <%--<asp:Panel ID="ItemContainer" runat="server">--%>
            <table width="100%" class="table-NoBorder">
                <tr class="tblHeader" bgcolor="#617E97">
                    <td width="50">
                        <b>Date</b>
                    </td>
                    <td width="35">
                        <b>Match</b>
                    </td>
                    <td width="100">
                        <b>City</b>
                    </td>
                    <td width="250">
                        <b>Hotel</b>
                    </td>
                    <td width="250">
                        <b>Address</b>
                    </td>
                    <td width="100">
                        <b>Phone</b>
                    </td>
                    <td width="100">
                        <b>Account</b>
                    </td>
...
</RadGrid>

然后是SqlDataSource:

<asp:SqlDataSource ID="SqlNotMatched" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ProlodgicConnectionString %>" 
    SelectCommand="sp_ds_ProdGroupMatch" SelectCommandType="StoredProcedure" DataSourceMode="DataSet" OnSelecting="SqlNotMatched_Selecting">
    <SelectParameters>
        <asp:ControlParameter Name="ConfidenceLvl" DefaultValue="50" ControlID="MatchConfidence" PropertyName="Text" />
        <asp:ControlParameter Name="FileID" DefaultValue="NULL" ConvertEmptyStringToNull="true" ControlID="FileID" PropertyName="SelectedValue" />
        <asp:ControlParameter Name="ProdGrpID" ControlID="ProdGroup" PropertyName="SelectedValue" />
        <asp:SessionParameter Name="SID" SessionField="SID" Type="String" />
    </SelectParameters>
</asp:SqlDataSource>  

现在是我遇到问题的地方,3个select命令参数是父页面上的3个控件(不在UC本身中),那么如何从控件中将这3个控件的值从我的SqlDataSource中获取? / p>

@Sam不确定你在问什么,但这里是我如何加载我的用户控件(它基于所选的RadioButtonList索引)

Dim uc = LoadControl("~/ProductionMatching.ascx")l
Placeholder1.Controls.Clear()
Placeholder1.Controls.Add(uc)

0 个答案:

没有答案