<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NWHCConnectionString %>"
SelectCommand="SELECT * FROM [AI_news]" OnSelecting="SqlDataSource1_Selecting">
</asp:SqlDataSource>
This is my code, I have followed the wizard perfectly the way its supposed ot be, well not 100% perfectly. This is how its supposed to be. When using a XXXX.MDF file I could use the wizard and it works fine. I do not know why my above code won't work. I am connected to the database and can view code manually. but not on a aspx page.
i am using master page, now trying to add this into default.aspx
Any help will be appreciated. I am currently losing some hair.
How are you trying to display the data? Have you bound a GridView to the SqlDataSource control? If not, add this:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="True" DataSourceID="SqlDataSource1"></asp:GridView>
I forgot to add a few things,
I am using Microsoft SQL Server (SqlClient).
with this code
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NWHCConnectionString %>"
SelectCommand="SELECT * FROM [AI_news]" OnSelecting="SqlDataSource1_Selecting">
</asp:SqlDataSource>
The code below compile fine, but doesn't show any results.
When I use Mikesdotnetting code, I receive this message.
The DataSourceID of 'GridView1' must be the ID of acontrol of type IDataSource. A control with ID 'SqlDataSource1' couldnot be found.
Lastly, I did not add anything in my webconfig file.
I will be working on this page while waiting for support.
|||
You need both on the page at the same time. The SqlDataSource only fetches the data. The GridView is what displays it.
I suggest you take the time to acquaint yourself with the basics. http://www.asp.net/learn/
Drag, drop and fingers crossed won't get you very far.
|||
What I am trying to do here is to display whatever information that is necessary to work from the database. I want to see if the data would at least work, I do not see any data displayed yet regardless how its displayed.
I will look into the tutorials
No comments:
Post a Comment