Stored procedures 如何将一个中继器与两个存储过程绑定在一起,这两个存储过程各有一列。第一个输出为ABCD,第二个输出为EBCD

Stored procedures 如何将一个中继器与两个存储过程绑定在一起,这两个存储过程各有一列。第一个输出为ABCD,第二个输出为EBCD,stored-procedures,Stored Procedures,如何将一个中继器与2个存储过程绑定,两个存储过程各有1列,1的输出是ABCD,然后第二个的输出是EBCD 更新 <asp:Repeater ....> <HeaderTemplate> [table rows and columns structure] </HeaderTemplate> <ItemTemplate> [table rows and columns structure]

如何将一个中继器与2个存储过程绑定,两个存储过程各有1列,1的输出是ABCD,然后第二个的输出是EBCD

更新

<asp:Repeater ....>
    <HeaderTemplate>
        [table rows and columns structure]
    </HeaderTemplate>
    <ItemTemplate>
        [table rows and columns structure]
    </ItemTemplate>
</asp:Repeater>

[表行和列结构]
[表行和列结构]
  • a和E的数据类型都是字符串
  • 我正在通过databind()将其绑定到db
  • 我的标记看起来像:
  • 谢谢你的回复

  • A列和E列的数据类型是什么
  • 您好吗?数据源ID?数据源/数据绑定()
  • 您的中继器中有什么标记
  • 在表示层(aspx页面),所有内容都是字符串,因此您可以将中继器绑定到任意一个结果,因为它们都有4列

    很难提供更多的帮助,因为您还没有展示您已经拥有的,而最佳解决方案在很大程度上取决于您项目的具体情况

    编辑

    好的,那就把它绑起来,你还没试过吗?你会发现,当你问技术问题时,如果你没有先尝试一些东西,我们就不太可能放弃我们的空闲时间来帮助你

    一个更好的问题是:“我曾尝试将我的中继器绑定到两个不同的存储过程,它们只相差一列,但我遇到了一个错误(请描述确切的错误消息)。这是我的代码……有人能帮忙吗?”

    可能的解决方案

    aspx

    <asp:Repeater ID="repeaterId" runat="server" 
        OnItemDataBound="RepeaterId_ItemDataBound">
        <HeaderTemplate>
            [table rows and columns structure]
        </HeaderTemplate>
        <ItemTemplate>
            <tr>
                <td><asp:Literal ID="literalId" runat="server"></td>
                <td><% # eval("column2")%></td>
                <td><% # eval("column3")%></td>
                <td><% # eval("column4")%></td>
            </tr>
        </ItemTemplate>
    
    protected void RepeaterId_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Literal lit = e.FindControl("literalId") as Literal;
            if(null != lit)
            {
                if(usingStoredProcedure1)
                {
                    lit.Text = Databinder.Eval(e.Item.DataItem, "A");
                }
                else
                {
                    lit.Text = Databinder.Eval(e.Item.DataItem, "E");
                }
            }
        }
    }
    
    private void BindRepeater()
    {
        if(someCondition == true)
        {
            repeaterId.DataSource = getStoredProcedure1();
        }
        else 
        {
            repeaterId.DataSource = getStoredProcedure2();
        }
    
        repeaterId.DataBind();
    }