new line and spacing

here i have a textbox which insert new data to MSaccess data base the point that when i enter any text in the textbox and insert it to DB and view the insert data in side a data grid the text that i nsert do not have any space and warp because of size of the tabel even when i use enter button in the end of each line to have a new line the data grid do not show it like that it puts alla the word with no spacing and no new line. so i think thjat the point is from the db . can you please advice me in this situation ....... thanks in advace... all that i want is to let the data base except multi line as enterd in textbox
Muhanad YOUNIS
MCSD.NET
My Blog || My Photos || LinkedIn

0
mohi88
6/12/2005 6:13:39 PM
asp.net.access-datasource 4679 articles. 0 followers. Follow

2 Replies
396 Views

Similar Articles

[PageSpeed] 36

When you retrieve the data from the database, assign it to a variable - like
dim myVar as string
myVar=Ds.Tables(0).Rows(0)("YourFieldname")

Then, what you need to do is take all the line feeds and change them to something that your HTML based browser understands.
Your line feeds are still there, inside the database, but the browser can't recognize them  - so use the replace function on your variable:

myVar=myVar.Replace(vbcrlf,"<br>")

Since you are putting this text inside a Datagrid, you'll need to create a helper function to do this
Function FormatData(sItem) as String
FormatData=sItem.Replace(vbcrlf,"<br>")
End Function

then, add a Columns collection to the DataGrid and provide for your data in an ItemTemplate:
<Columns>
  <asp:TemplateColumn>
      <ItemTemplate>
         <%# FormatData(Container.DataItem("YourFieldname) %>
      </ItemTemplate>
  </asp:TemplateColumn>
</Columns>
David Wier
MCP/ASPInsider
ASPNet101.com - where to look first!
Control Grouper - easily control properties for multiple controls with one control!
Calendar Express - The Best HTML Calendar Generator on the web!
(Please 'Mark as Answer' when it applies)
0
augustwind
6/12/2005 6:32:44 PM
actualy i di dnot understan your point , i`m coding with c# i donot understand vb well 
but here is the whole code and the insert code
so what kind of change that i have to do 

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.Data.OleDb;




namespace Makale.yonetim
{
	/// 
	/// Summary description for kategori.
	/// 
	public class kategori : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.DataGrid DataGrid1;
		
		protected System.Web.UI.WebControls.Panel Panel1;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.TextBox TextBox1;
		protected System.Web.UI.WebControls.Button Button1;
		OleDbConnection relconn;
		
		protected System.Web.UI.WebControls.TextBox TextBox2;
		protected System.Web.UI.WebControls.Label Label2;
		OleDbCommand cmd;
		private void Page_Load(object sender, System.EventArgs e)
		{
			if(!IsPostBack)
			{
				BindDataGrid();
			}
		
		}
		#region data grid bind 
		void BindDataGrid()
		{
			
			
			Baglantilar.olebaglanti mmy=new Baglantilar.olebaglanti();
			relconn=new OleDbConnection(String.Format(mmy.yonetimbaglantisi(),Server.MapPath(".")));
			
			
			cmd=new OleDbCommand("Kategori_sirala",relconn);
			cmd.CommandType=CommandType.StoredProcedure;
			relconn.Open();
			this.DataGrid1.DataSource=cmd.ExecuteReader();
			this.DataGrid1.DataBind();
			relconn.Close();
			this.TextBox1.Text="";
			this.TextBox2.Text="";
		}
		#endregion
		#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);
		}
		
		/// 
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// 
		private void InitializeComponent()
		{    
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.DataGrid1.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_CancelCommand);
			this.DataGrid1.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_EditCommand);
			this.DataGrid1.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_UpdateCommand);
			this.DataGrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
		#region edit and cancel
		private void DataGrid1_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			this.DataGrid1.EditItemIndex=-1;
			BindDataGrid();
		}

		private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			this.DataGrid1.EditItemIndex=e.Item.ItemIndex;
			BindDataGrid();
		}
		#endregion
		#region update
		private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			Baglantilar.olebaglanti mmy=new Baglantilar.olebaglanti();
			relconn=new OleDbConnection(String.Format(mmy.yonetimbaglantisi(),Server.MapPath(".")));
			string strkategori;
			string strkaciklama;
			int kate_id;
			kate_id=(int)this.DataGrid1.DataKeys[e.Item.ItemIndex];

			TextBox kate=(TextBox)e.Item.Cells[1].Controls[0];
			TextBox kaacik=(TextBox)e.Item.Cells[2].Controls[1];
			
			strkategori=Server.HtmlDecode(kate.Text);
		strkaciklama=Server.HtmlDecode(kaacik.Text);

			cmd=new OleDbCommand("kategori_guncel",relconn);
			cmd.CommandType=CommandType.StoredProcedure;
			cmd.Parameters.Add("@forumadi",Server.HtmlEncode(strkategori));
		cmd.Parameters.Add("@forumacik",Server.HtmlEncode(strkaciklama));
			cmd.Parameters.Add("@id",kate_id);

			relconn.Open();
			cmd.ExecuteNonQuery();
			relconn.Close();
			this.DataGrid1.EditItemIndex=-1;
			BindDataGrid();
	
		
		}
		#endregion
		#region delete
		private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			Baglantilar.olebaglanti mmy=new Baglantilar.olebaglanti();
			relconn=new OleDbConnection(String.Format(mmy.yonetimbaglantisi(),Server.MapPath(".")));

			int kate_id;
			kate_id=(int)this.DataGrid1.DataKeys[e.Item.ItemIndex];
			cmd=new OleDbCommand("kategori_sil",relconn);
			cmd.CommandType=CommandType.StoredProcedure;
			cmd.Parameters.Add("@id",kate_id);
			relconn.Open();
			cmd.ExecuteNonQuery();
			relconn.Close();
			this.DataGrid1.EditItemIndex=-1;
			BindDataGrid();
		
		}
#endregion
		#region kategoriekle
		private void Button1_Click(object sender, System.EventArgs e)
		{
			Baglantilar.olebaglanti mmy=new Baglantilar.olebaglanti();
			relconn=new OleDbConnection(String.Format(mmy.yonetimbaglantisi(),Server.MapPath(".")));

			string kategoriEkle;
			string strkatacik;
			kategoriEkle=this.TextBox1.Text;
			strkatacik=this.TextBox2.Text;
			
			cmd=new OleDbCommand("kategori_ekle",relconn);
			cmd.CommandType=CommandType.StoredProcedure;
			cmd.Parameters.Add("@forumadi",kategoriEkle);
			cmd.Parameters.Add("@forumacik",strkatacik);
			relconn.Open();
			cmd.ExecuteNonQuery();
			relconn.Close();
			
			BindDataGrid();
		}
		#endregion

		
	}
}
Muhanad YOUNIS
MCSD.NET
My Blog || My Photos || LinkedIn

0
mohi88
6/12/2005 6:45:05 PM
Reply:

Similar Artilces:

Line spacing, word spacing, char spacing
I already found out line , word and char spacing are not foreseen in GDI+.According to some websites, the MeasureString method does not work the way it should. (which I could use to manually change the X/Y positions etc.)Does anyone know of a component that will do the trick?And preferrably not one that will cost me hundreds of euros :)All I want to do is put some text on an image ...The only problem being is that line, word and char spacing are strict requirement.Seems easy, but I'm quite desperate so thank you for your early reply....

New to .net
Hi all! >Can anyone explain to me this line? this.UpdateBtn.Click += new System.Web.UI.ImageClickEventHandler(this.UpdateBtn_Click); >why do they use the += operator? >how can i know when to use += or simply "obj=new class()" ?? THanks so much LAM Hi, ''+'' Operator is used to specify that The Event is being added to the Control. This is how we add the Event to the Control Dynamically.HighOnCodingWanna get high! First of all thx for the quick answer! I figured they were adding something, but what event are they exactly adding? this...

New to .NET
Hi, I have been working with asp for a while on my windows 200 machine running iis5 with no problems. I have the .net framework install and is appearing in the applications tab of iis. My problem is that if I execute a .net app I get the following error: Server Error in '/test' Application. Server cannot access application directory 'C:\Documents and Settings\Administrator\My Documents\test\'. The directory does not exist or is not accessible because of security settings. Description: An unhandled exception occurred during the execution of the current web request. Please r...

new line is changed in space character
Hallo, when I submit the data of a multiline textarea the new line is changed into a space character. If the user write: A B C The text will be displayed as: A B C I am using a datalist with parameter stored procedure, Access 2003 DB. Do you have a solution? Thanks   before you send in the data you can do something like : txtstmtbdy1.text.replace(environment.newline,"<br>")  to preserve the newline's.***********************Dinakar NethiLife is short. Enjoy it.***********************...

NEW NEW NEW
hi I have a huge form to build on an asp.net page with multiple fields  that come from and also connect to (postback=true) 10 different tables{database is access for now } .which controls would be helpful please suggest. Also how about usign infopath to build forms and hosting it on iis is it feasible..please advice. Thanks in advance Environment: Visual studio 2005 ,iis webserver,ms access,Thanks to all the PROS who are helping other developers.. Hi, For ASP.NET 2.0 Hosting purpose I am currently using GoDaddy.com. And satisfied with the service.RegardsKuldeep Deokule&nbs...

accessing MS Access from .net
hi I am accessing ms access data base which has a table called customers. when i try to insert data into the table i am gettign the error like "Operation must use an updatable query" and the line its showing is myOleDbcommand.ExecuteNonQuery() here is my code in page lode event Sub Page_Load(Sender As Object, E As EventArgs) Dim StrConnectString as String Dim strStatement as String strConnectSTring = "Provider=Microsoft.Jet.OLEDB.4.0;Password='';User ID=Admin;Data Source=C:\Inetpub\wwwroot\Srinu\WebApplication2\...

Writing .net code to text file has no new lines
I'm building a CMS, which when a new page is created it reads a template file from text, puts a pageId in the file and saves it as 'whatever.aspx', this page has c#.net code inside it which uses the pageId to get the page content from a database. My problem is that when the code is written to file it seems to lose all it's new line declarations, so everything is on one line and the code won't run. here is the code I'm using to write the file to disk. using (StreamWriter streamWriter = File.CreateText(MapPath("../"+newFilename+".aspx"))){&nb...

Space in the url line causes new tab to open
Name: Allen Huff Email: algen3_at_comcast.net Product: Firefox Summary: Space in the url line causes new tab to open Comments: When opening a file say c:/temp/new.jpg firefox works fine but when you open the same file under c:/temp file/new.jpg firefox will try to open everything before the space c:/temp with obnoxious results then "file" will be searched in a new tab and some crappy website about files will come up then another tab will come up saying it cannot find the file Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/2005111...

New Article: .NET Data Access Performance Comparison
A new article has been published on AspAlliance.com: .NET Data Access Performance Comparison This article attempts to compare several different data access techniques through the use of a stress testing tool. DataTables and DataReaders are compared with a number of different variables, and recommendations for best practices are provided. Everbody knows (or should) that DataReaders can be dangerous -- you might be surprised to learn *how* dangerous they can be if you don't use them properly.Steven A SmithAspAlliance.com - The #1 ASP.NET CommunityDevAdvice.com - Answers to Questio...

New line spacing in Ver. 2.2.2
Hi, since version 2.2.2 there's a new linespacing in all seamonkeys windows. It looks horrible and you see less lines as before. Is there any option to change this like it was before,I found none. Or can me anyone tell who I can ask to change it in a newer version. Greetings klaurosch klaurosch@gmail.com wrote: > since version 2.2.2 there's a new linespacing in all seamonkeys windows. It looks horrible and you see less lines as before. > Is there any option to change this like it was before,I found none. > Or can me anyone tell who I can ask to change it in a n...

Insert a new line into an access database via button click
I am curious.  With a webpage written with vb.net ; is it possible that when someone clicks on a "Button" just a plain old button. So on button.click  insert the number 5 in a collum in an access database? If you are asking whether a button can be placed on a web-page that can call a server-side event that inserts a row into a database then the answer is "yes". You may wish to read for http://quickstarts.asp.net/QuickStartv20/aspnet/doc/data/databases.aspx#insert  for more info. Thank you ...

Strange lines in new web.config (.NET 3.5)?
What do the lines below mean? They appeared in my .NET 2.0->.NET 3.5-project after the conversion. The new .NET 3.5 System.Web.Extensions is referenced to earlier in the assemblies section, so I can't figure out what these lines do? I dont want to remove them, "dependentAssembly" seems important. Does this mean I can't remove my old ASP.NET AJAX assemblies from GAC? Thanks in advance!<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Extensions&qu...

How do I add line spacing when sending an email through System.Net.Mail?
To make things easier to read, I would like to end some lines short and start new paragraphs. However, the page doesn't like when I use "<br />" in the mail.Body = I am using VB.net, ASP.net, and SQL Server. Thanks, in advance. Hi, did you set the isBodyHtml property to true? Take a look here for more information: 3.1.2 How do I send a simple Html email? Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons. Kris is right, also, if you don't wnat to use html, you can use newline: \n  ...for ...

VB.NET IDE Editor Slow Between Inserting New Lines
When in a VB.NET project, if I'm writing code, and I enter a new line, there is about a 5-15 second pause like its trying to parse what I've done so far. I don't have this issue when coding C# projects, however, the company has decided to use VB.NET as the primary .NET language and all this waiting between lines is taking up a lot of my time. One work around I have discovered is if I have syntactical errors, or if I place a garbage string at the top of the file like "afadfasdfas" it does not have this slow down. One common thing I did notice, that in C# if I have dynamic help...

Web resources about - new line and spacing - asp.net.access-datasource

Sentence spacing - Wikipedia, the free encyclopedia
Early American, English, and other European typesetters' style guides (also known as printers' rules ) specified spacing standards that were ...

Spacing Guild
jurvetson posted a photo: No photoshop here... I think they can fold space...

Blink-182's Tom DeLonge talks about space and UFOs - Spacing Out! Ep. 32 - YouTube
Tom DeLonge is a well-known and accomplished musician. But in addition to his impressive musical career, Tom has an impressive level of knowledge ...

Cottage Life, Spacing lead at CSME awards with four wins
Feature 1 Cottage Life and Spacing both picked up four awards at the Canadian Society of Magazine Editors awards in Toronto on June 4. Photo ...

Dyslexic kids read better with wider spacing of letters - People's Daily Online
Europeanresearcherssayreadingmaterialswithwiderspacingbetweentheletterscanhelpdyslexic

Kindle for iOS adds line spacing, multipage highlights, accessibility improvements, more
Line Spacing Amazon updated its Kindle iOS app today with a number of notable improvements. Included in version 3.8 of the app is the ability ...

Kindle For iOS Update Brings New Line Spacing Options
... with a slate of new features that should make any e-book reader happy. First up, version 3.8 of the app is highlighted by new line spacing ...

Thoughts and Concerns on Sibling Spacing: What's the Right Age Difference?
... bit closer, I think more like 2-1/2 years (correct me if I'm wrong, Kathy!) . I suppose my own experience has played a role in our child spacing ...

"I literally was spacing out because I’m in such a rage spiral about that guy."
"I was just looking at him looking at him and going into this rage [over] this idea that you would talk to a woman like that and accuse a woman ...

Dys app increases reading speed in dyslexics by altering letter spacing
Talk about applied science. Wrote Robert Lee Hotz in a June 4 Wall Street Journal story, "Children with dyslexia can read faster and more accurately ...

Resources last updated: 12/11/2015 6:33:46 PM