Problem in getting list of users

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 anni tempo fa
I am trying to place a datalist which will include the list of all the users
I want to make each username as hyperlink so that if anyone click on the username it should navigate to the profile page:

I am doing this :

<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
                    <ItemTemplate>
                  <asp:HyperLink ID="HyperLink1" runat="server"
                            NavigateUrl='<%# string.Format("~/profile.aspx?userid={0}", Eval("Customer_ID"))%> '
                            Text='<%# Bind("Username") %>'></asp:HyperLink>
                    </ItemTemplate>

                </asp:DataList>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                ConnectionString="Data Source=.\SQLEXPRESS;Initial Catalog=nop17;Integrated Security=True"
                ProviderName="System.Data.SqlClient"
                SelectCommand="SELECT Username FROM Nop_Customer"></asp:SqlDataSource>

------------

DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Customer_ID'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Customer_ID'.

Source Error:


Line 26:          <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
Line 27:                     <ItemTemplate>
Line 28:                         <asp:HyperLink ID="HyperLink1" runat="server"
Line 29:                             NavigateUrl='<%# string.Format("~/profile.aspx?userid={0}", Eval("Customer_ID"))%> '
Line 30:                             Text='<%# Bind("Username") %>'></asp:HyperLink>
13 anni tempo fa
anyone ?
13 anni tempo fa
anyone please ?
13 anni tempo fa
abcd_12345 wrote:
I am trying to place a datalist which will include the list of all the users
I want to make each username as hyperlink so that if anyone click on the username it should navigate to the profile page:

I am doing this :

<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
                    <ItemTemplate>
                  <asp:HyperLink ID="HyperLink1" runat="server"
                            NavigateUrl='<%# string.Format("~/profile.aspx?userid={0}", Eval("Customer_ID"))%> '
                            Text='<%# Bind("Username") %>'></asp:HyperLink>
                    </ItemTemplate>

                </asp:DataList>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                ConnectionString="Data Source=.\SQLEXPRESS;Initial Catalog=nop17;Integrated Security=True"
                ProviderName="System.Data.SqlClient"
                SelectCommand="SELECT Username FROM Nop_Customer"></asp:SqlDataSource>

------------

DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Customer_ID'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Customer_ID'.

Source Error:


Line 26:          <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
Line 27:                     <ItemTemplate>
Line 28:                         <asp:HyperLink ID="HyperLink1" runat="server"
Line 29:                             NavigateUrl='<%# string.Format("~/profile.aspx?userid={0}", Eval("Customer_ID"))%> '
Line 30:                             Text='<%# Bind("Username") %>'></asp:HyperLink>



There are a couple of errors: Customer_ID should be CustomerID and you need to include it in your query ("SELECT CustomerID, Username FROM Nop_Customer").

.
13 anni tempo fa
thanks mb for pointing out my silly mistakes...
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.