|
Hi,
Is it normal this code doesn't work yet
?
It doesn't throw any exceptions, and the datagrid
actually gets the columns from the database
so I can see
"id","name","description","status","author" as the headers for the columns, but
it doesn't show the records.
------------------------------------------------------------------------------------------------------------------------
<%@ Page Language="C#" %>
<%@ import Namespace="ByteFX.Data.MySQLClient" %> <%@ import Namespace="System.Data" %> <script runat="server"> // Insert page code
here
// void Page_Load(object sender, EventArgs e) { //Create a new connection object MySQLConnection dbConnection = new MySQLConnection(@"Data Source=localhost;Port=3306;Database=dev;User ID=rded;Password=sdec4;COMMAND LOGGIN=false"); //Create the query string string sqlQuery = "SELECT * FROM object"; //Create a new command object MySQLCommand dbCommand = new MySQLCommand(sqlQuery,dbConnection); //Open the connection dbConnection.Open(); //Create a new DataAdapter MySQLDataAdapter dbAdapter = new MySQLDataAdapter(dbCommand); //Create a new DataSet DataSet dbObjects = new DataSet(); //Fill it dbAdapter.Fill(dbObjects,"objects"); //Close the data adapter dbConnection.Close(); //Bind dgrObjects.DataSource = dbObjects.Tables["objects"]; dgrObjects.DataBind(); } </script>
<html> <head> </head> <body> <form runat="server"> <p> </p> <p> </p> <p> <strong>Current objects:</strong> </p> <p> <asp:DataGrid id="dgrObjects" runat="server" Width="100%" BorderStyle="None" BorderWidth="1px" BorderColor="#CCCCCC" BackColor="White" CellPadding="3"> <FooterStyle forecolor="#000066" backcolor="White"></FooterStyle> <HeaderStyle font-bold="True" forecolor="White" backcolor="#006699"></HeaderStyle> <PagerStyle horizontalalign="Left" forecolor="#000066" backcolor="White" mode="NumericPages"></PagerStyle> <SelectedItemStyle font-bold="True" forecolor="White" backcolor="#669999"></SelectedItemStyle> <ItemStyle forecolor="#000066"></ItemStyle> </asp:DataGrid> <!-- Insert content here --> </p> </form> </body> </html> --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.491 / Virus Database: 290 - Release Date: 18/06/2003 |
- Re: [Mono-list] ASP.NET - DataGrid DataBinding Timothy Parez
- Re: [Mono-list] ASP.NET - DataGrid DataBindin... Gonzalo Paniagua Javier
- Re: [Mono-list] ASP.NET - DataGrid DataBi... Timothy Parez
