locked
How to assign DataSourceID to asp:Repeater in javascript using a web method RRS feed

  • Question

  • User-1061779338 posted

    Hi,

      I need to assign Datasourceid to a repeater control .. So far i am using the below code which works fine for me.. But due to some security reasons i need not to show the storedproc name in the aspx page. So is there any way to bind the data to repeater by removing the SelectCommand="EXEC GetDetailData_CustLinked @cust_xref_id" and using a webservice to assign the data..

     

    <asp:Repeater ID="repCustProfileLinked" DataSourceID="SQLCustomerLinked" Visible="true" runat="server" EnableViewState="false">

     

    <asp:SqlDataSource ID="SQLCustomerLinked" ConnectionString='<%$ EnviromentConnectionString:ConnectionString %>'

     ProviderName="System.Data.SqlClient" SelectCommand="EXEC GetDetailData_CustLinked @cust_xref_id" runat="server">

     <SelectParameters>

     

     <asp:ControlParameter ControlID="cust_xref_valuelinked" PropertyName="Text" Type="Int64" Name="cust_xref_id" />

     </SelectParameters>

     </asp:SqlDataSource>

    Thanks,

    bboys.

    Tuesday, May 10, 2011 5:12 PM

Answers

  • User3866881 posted

    Hi:)
    In my opinion, you shouldn't use any DataSource controls directly. But just use DataAdapter to bind to the Repeater manually, something looks like this below:

    using (SqlDataAdapter adapter = new SqlDataAdpater("Your stored procdure's name"), new SqlConnection(……))

    {

              adapter.SelectCommand.CommandType = CommandType.StoredProcdure;

              DataTable dt = new DataTable();

              adapter.Fill(dt);

             Repeater1.DataSource = dt;

              Repeater1.DataBind();

    }

    In this way, you cannot see the stored procdure's name anymore.

    Thx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 11, 2011 9:44 PM

All replies

  • User-1360095595 posted
    If thE stored procedure name causes a security vulnerability, maybe you need to rethink your security altogether. But anyway, to answer your question, you can set the selectcommand in the code behind instead.
    Tuesday, May 10, 2011 5:18 PM
  • User3866881 posted

    Hi:)
    In my opinion, you shouldn't use any DataSource controls directly. But just use DataAdapter to bind to the Repeater manually, something looks like this below:

    using (SqlDataAdapter adapter = new SqlDataAdpater("Your stored procdure's name"), new SqlConnection(……))

    {

              adapter.SelectCommand.CommandType = CommandType.StoredProcdure;

              DataTable dt = new DataTable();

              adapter.Fill(dt);

             Repeater1.DataSource = dt;

              Repeater1.DataBind();

    }

    In this way, you cannot see the stored procdure's name anymore.

    Thx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 11, 2011 9:44 PM
  • User-1061779338 posted

    hI dECKER,

       Thanks for the reply :) .. Its working..

    Thursday, May 12, 2011 6:04 PM