[Mono-list] Fwd: GridView with Mono Server

Praveen Kumar praveen at mahiti.org
Fri Mar 14 02:24:53 EDT 2008


---------- Forwarded message ----------
From: Praveen Kumar <praveen at mahiti.org>
Date: Mar 14, 2008 11:33 AM
Subject: GridView with Mono Server
To: mono-list at lists.ximian.com

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


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)
        {
        test();
        Page.Response.Write(" Me called on page Load");
        //txt_username.Text="Hi";
        }
    override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form
Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }
    private void InitializeComponent()
        {
            //this.btn_password.Click += new System.EventHandler(
this.btn_password_Click);
            //this.Button1.Click += new System.EventHandler(
this.Button1_Click);
            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;
        try
        {
            string connectionString =
                  "Server=192.168.2.140;" +
                  "Database=employee;" +
                  "User ID=praveen;" +
                  "Password=;" +
                  "Pooling=false";
                   dbcon = new MySqlConnection(connectionString);
                   dbcon.Open();
                   //dbcmd = dbcon.CreateCommand();
                string sql =
                   "SELECT firstname, lastname " +
                   "FROM employee";
                   //dbcmd.CommandText = sql;
            dbcmd=new MySqlCommand(sql,dbcon);
GridView1.DataSource=dbcmd.ExecuteReader();
GridView1.DataBind();
GridView gv=(GridView)FindControl("GridView1");
        Page.Response.Write(gv);
//da=new MySqlDataAdapter(sql,dbcon);
//da.Fill(ds);
//GridView1.DataSource=ds;
//GridView1.DataBind();
                   //reader = dbcmd.ExecuteReader();
            //Page.Response.Write(reader);
                   /*while(reader.Read())
            {
                //GridView1.DataSource=reader["firstname"];
                //GridView1.DataBind();
                        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)
        {
            Page.Response.Write(e1);
        }//end of catch
        finally{

            }//end of finally

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

}
}

-- 
Praveen Kumar
Software Engineer
Mahiti Infotech Pvt. Ltd.
# 33-34, Hennur Cross
Hennur Main Road
Bangalore, India - 560043
Mobile:  +91 9343297314
             +91 9739854134
http://www.mahiti.org


-- 
Praveen Kumar
Software Engineer
Mahiti Infotech Pvt. Ltd.
# 33-34, Hennur Cross
Hennur Main Road
Bangalore, India - 560043
Mobile:  +91 9343297314
             +91 9739854134
http://www.mahiti.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20080314/37d6c436/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/37d6c436/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/37d6c436/attachment-0001.bin 


More information about the Mono-list mailing list