Rookie
05-30-2006, 06:59 AM
Hi,
I am trying to use VS 2005 for the first time and I am having trouble retrieving data from my MSSQL 2005 database. I used the drag and drop controls in VS 2005 to create a datagrid on the page and used the wizard to select the fields I want want to display in the grid. I feel like I did everything correctly but I am not getting any data when I access the page (it's just blank, and there should be 2 records). Sorry, I am a beginner at this. Any help would be much appriciated
Here is what the .aspx page looks like:
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display." ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />\
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:KRConnectionString1 %>" OnSelecting="SqlDataSource1_Selecting" ProviderName="<%$ ConnectionStrings:KRConnectionString1.ProviderName %>" SelectCommand="SELECT [Date], [Text] FROM [TEST]"></asp:SqlDataSource>
</div>
</form>
Here is the C# code:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
I am trying to use VS 2005 for the first time and I am having trouble retrieving data from my MSSQL 2005 database. I used the drag and drop controls in VS 2005 to create a datagrid on the page and used the wizard to select the fields I want want to display in the grid. I feel like I did everything correctly but I am not getting any data when I access the page (it's just blank, and there should be 2 records). Sorry, I am a beginner at this. Any help would be much appriciated
Here is what the .aspx page looks like:
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display." ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />\
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:KRConnectionString1 %>" OnSelecting="SqlDataSource1_Selecting" ProviderName="<%$ ConnectionStrings:KRConnectionString1.ProviderName %>" SelectCommand="SELECT [Date], [Text] FROM [TEST]"></asp:SqlDataSource>
</div>
</form>
Here is the C# code:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}