I first make an ArrayList, I connect to the database and put the data from the database in the ArrayList. Then i put the data from the ArrayList into a DataGrid.
The problem is that I add some memo-fields to my ArrayList, and when the memo field is placed in my DataGrid, all my hard enters are gonna, so all the text is sticked together.
Does anyone have a solution for this problem?
Language use C# in asp.net.
Code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Crittlists
{
/// <summary>
/// Summary description for HaatStrijd2.
/// </summary>
public class HaatStrijd2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.DataGrid dgridCrittlist;
private void Page_Load(object sender, System.EventArgs e)
{
ArrayList crittlist=new ArrayList();
string mage= Request.QueryString["Magename"];
OleDbConnection DB = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:/Inetpub/wwwroot/Crittlists/mages.mdb");
DB.Open();
OleDbCommand rsCrittlist = new OleDbCommand("select crittlist from mage where magename='"+mage+"';", DB);
OleDbDataReader rdCrittlist = rsCrittlist.ExecuteReader();
while (rdCrittlist.Read())
{
crittlist.Add(rdCrittlist.GetString(0));
}
rdCrittlist.Close();
DB.Close();
dgridCrittlist.DataSource=crittlist;
dgridCrittlist.DataBind();
dgridCrittlist.AllowSorting.ToString();
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}