[Mono-list] GridView with Mono Server

Praveen Kumar praveen at mahiti.org
Fri Mar 14 01:54:33 EDT 2008

Hello all and one,
For me Its a great acchievement i have completely configured MONO, .net with
MySql running in ubuntu os. now i can run my .Net2.0 Project on Ubuntu OS.
But i stucked in my project while i am using GridView. I am not able to bind
GridView with records. i have applied all the way by using
DataReader,DataAdapter,DataTable but could not succeed. i have attached my
code with this mail. please do check.
i am compiling my login.aspx.cs with gmcs compiler
gmcs /t:library /out:WebApplication.dll -r:System.Web -r:System.Data -r:
login.aspx.cs Global.asax.cs
this is my code
using System;
using System.Data;
using System.Data.Common;
using System.ComponentModel;
using System.Drawing;
using System.Configuration;
using System.Collections;
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;
using System.Web.SessionState;
//using System.Data.Odbc;
using MySql.Data.MySqlClient;

namespace Demo
public class data : System.Web.UI.Page
GridView GridView1;

     protected void Page_Load(object sender, EventArgs e)
        Page.Response.Write(" Me called on page Load");
    override protected void OnInit(EventArgs e)
            // CODEGEN: This call is required by the ASP.NET Web Form
    private void InitializeComponent()
            //this.btn_password.Click += new System.EventHandler(
            //this.Button1.Click += new System.EventHandler(
            this.Load += new System.EventHandler(this.Page_Load);
    public void test()

        /*IDataReader reader;
        IDbConnection dbcon;
        IDbCommand dbcmd;*/
        MySqlDataReader reader;
        MySqlConnection dbcon;
        MySqlCommand dbcmd;
        MySqlDataAdapter da;
GridView1=new GridView();
        DataTable dt;
        DataSet ds;
            string connectionString =
                  "Server=;" +
                  "Database=employee;" +
                  "User ID=praveen;" +
                  "Password=;" +
                   dbcon = new MySqlConnection(connectionString);
                   //dbcmd = dbcon.CreateCommand();
                string sql =
                   "SELECT firstname, lastname " +
                   "FROM employee";
                   //dbcmd.CommandText = sql;
            dbcmd=new MySqlCommand(sql,dbcon);
GridView gv=(GridView)FindControl("GridView1");
//da=new MySqlDataAdapter(sql,dbcon);
                   //reader = dbcmd.ExecuteReader();
                        string FirstName = (string) reader["firstname"];
                        string LastName = (string) reader["lastname"];
                        Page.Response.Write("Name: " +
                          FirstName + " " + LastName);

            }// end of while*/

        }//end of try
        catch(Exception e1)
        }//end of catch

            }//end of finally

    }// end of test
   /*private void Button1_Click(object sender, EventArgs e)
        //Login(txt_username.Text, txt_password.Text);

}///end of code

Please help me as soon as possible.

Praveen Kumar
Software Engineer
Mahiti Infotech Pvt. Ltd.
# 33-34, Hennur Cross
Hennur Main Road
Bangalore, India - 560043
Mobile:  +91 9343297314
             +91 9739854134
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20080314/c125e1a2/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: login.aspx
Type: application/octet-stream
Size: 5029 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-list/attachments/20080314/c125e1a2/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: login.aspx.cs
Type: text/x-csharp
Size: 3768 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-list/attachments/20080314/c125e1a2/attachment-0001.bin 

More information about the Mono-list mailing list