locked
DataList does not display RRS feed

  • Question

  • User451945003 posted

    DataList will not display - doesn't  DataList.DataBind()  execute cause the stored procedure to run?

    <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource2" RepeatColumns="5" RepeatDirection="Horizontal"> <ItemTemplate>
    GalleryName: <asp:Label ID="GalleryNameLabel" runat="server" Text='<%# Eval("GalleryName") %>' /> <br />
    ID2: <asp:Label ID="ID2Label" runat="server" Text='<%# Eval("ID2") %>' /> <br />
    </ItemTemplate>
    </asp:DataList>

    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:TTL2ConnectionString %>" SelectCommand="NewCategories" SelectCommandType="StoredProcedure">
    <SelectParameters>
    <asp:ControlParameter ControlID="tbxK0" DefaultValue="" Name="Kwrd0" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="tbxK1" DefaultValue="" Name="Kwrd1" PropertyName="Text" Type="String" />
    <asp:ControlParameter ControlID="tbxK2" DefaultValue="" Name="Kwrd2" PropertyName="Text" Type="String" />
    </SelectParameters> </asp:SqlDataSource>

    C# code Behind

    protected void Page_PreRender(object sender, EventArgs e)
    {    DataList1.DataBind();    }

    Tuesday, April 30, 2013 8:26 PM

Answers

  • User-1716253493 posted

    After databound check it:

    Label1.Text = DataList1.Items.Count.ToString();

    Would you like to post the sp?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 30, 2013 9:07 PM

All replies

  • User-1716253493 posted

    The problem look like from your stored procedure that no results.

    Usualy, using sqldatasource no need calling databind()

    Tuesday, April 30, 2013 8:35 PM
  • User451945003 posted

    SP runs fine and is used as datasource for several GridViews.  Executed it in VisualStudio and works.

     

    Tuesday, April 30, 2013 8:46 PM
  • User-1716253493 posted

    After databound check it:

    Label1.Text = DataList1.Items.Count.ToString();

    Would you like to post the sp?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 30, 2013 9:07 PM
  • User451945003 posted

    You were correct.  The display parameters of the page prevented the DataList from being seen.  It did exist but was "invisible".  Thank you for label text tip.

    Tuesday, April 30, 2013 10:06 PM