ASP.NET populates ListView with stored procedure

I am trying to populate ASP.NET LISTVIEW using a stored procedure (@ param1) . Can someone please tell me if this is at all possible. If possible, showing me a few lines of code will be very helpful.

+3
source share
1 answer

See Data Points Elements: Data Source Controls in ASP.NET 2.0 on MSDN for a nice overview of how to use SqlDataSourcedata-compatible controls in your web application.

Basically, you need a SqlDataSource

<asp:SqlDataSource ID="sdsYourData" Runat="server"
    ProviderName="System.Data.SqlClient"
    ConnectionString="Server=(local);Database=Northwind;Integrated Security=SSPI;"
    SelectCommand="dbo.YourStoredProcName" 
    <SelectParameters>
        <asp:Parameter Name="Param1" Type="String" />>
     </SelectParameters>
</asp:SqlDataSource>

, ( ) - , - ? ASP.NET? <SelectParameters>.

, :

<asp:ListView id="listView1" runat="server"
              DataSourceID="sdsYourData"
              DataTextField="SomeTextField" 
              DataValueField="YourIDField" />

:

  • SQL (DataTextField)?
  • SQL ASP.NET, (DataValueField)?
+3

All Articles