469,299 Members | 2,073 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,299 developers. It's quick & easy.

Assigning multiline text to datagrid

Hi,

I have multiline textbox in which i am getting suggestions from user and storing in MS ACCESS table.

While i displaying in datagrid, the text is not coming as multiline. Instead it was binding as continuous line.

ex: input
test1
test2
test3

in datagrid it is displaying as test1 test2 test3

any idea to resolve this.
May 12 '07 #1
9 2153
shweta123
692 Expert 512MB
Hi,

My guess is that you should check the max length for the multiline textbox.
If it's MaxLenght is already greater than the input ,it will show you it in the same line instead of multiple lines.
May 13 '07 #2
gomzi
304 100+
Hi,

I have multiline textbox in which i am getting suggestions from user and storing in MS ACCESS table.

While i displaying in datagrid, the text is not coming as multiline. Instead it was binding as continuous line.

ex: input
test1
test2
test3

in datagrid it is displaying as test1 test2 test3

any idea to resolve this.
If you want to display the output on different lines (i.e. same as input) in a datagrid, then you will have to use a literal tag .
place the literal inside the template field and bind the output from the db to the literal tag.
Also, see to it that before binding the output to the literal tag, you convert the line breaks to <br/>,
i.e. replace vbCrLf in the string that you are binding to <br/>
May 13 '07 #3
Thanks Gomzi,

How can i place litreal tag in template column. I mean where the literal tag is and how can i write codings to convert the line breaks to <br/>
May 14 '07 #4
gomzi
304 100+
Thanks Gomzi,

How can i place litreal tag in template column. I mean where the literal tag is and how can i write codings to convert the line breaks to <br/>

Try this,
Expand|Select|Wrap|Line Numbers
  1.        <asp:GridView ID="GridView1" runat="server">
  2.             <Columns>
  3.                 <asp:TemplateField>
  4.                     <ItemTemplate>
  5.                         <asp:Literal ID="litsomething" runat="Server"></asp:Literal>
  6.                     </ItemTemplate>
  7.                 </asp:TemplateField>
  8.             </Columns>
  9.         </asp:GridView>
  10.  
IN CODE BEHIND,
In page load or whereever you are binding the dataset to a datagrid, run a loop to replace the vbCrLf to <br/> for that column before binding.
THEN,
Expand|Select|Wrap|Line Numbers
  1.  
  2. Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
  3.         If e.Row.RowType = DataControlRowType.DataRow Then
  4.             CType(e.Row.FindControl("litsomething"), Literal).Text = e.Row.DataItem("yourcolumnname")
  5.         End If
  6.     End Sub
  7.  
May 14 '07 #5
Hi Gomzi,

sorry for disturbing you.

still i am not clear. i am doing program in asp.net using vb coding.

could you please explain in detail.
May 15 '07 #6
gomzi
304 100+
Hi Gomzi,

sorry for disturbing you.

still i am not clear. i am doing program in asp.net using vb coding.

could you please explain in detail.
Did you try out the code that i posted last time?
If yes, are you getting any output? or any errors?
May 15 '07 #7
Yes. your coding is working properly.

There is no error in it.

But i not got solution for my question.

I need to display multiline content as such. For Ex: if there is 10 lines in database means i need to display as such.But your coding is not helpful for me.

Because it is displaying the content as a single line. It is not considering more than one space and even the next line.

I need to display the following sample coding in datagrid as such.

This is for testing
multiline
option display in
datagrid
<blank spaces>using asp.net

any idea.
May 18 '07 #8
gomzi
304 100+
Yes. your coding is working properly.

There is no error in it.

But i not got solution for my question.

I need to display multiline content as such. For Ex: if there is 10 lines in database means i need to display as such.But your coding is not helpful for me.

Because it is displaying the content as a single line. It is not considering more than one space and even the next line.

I need to display the following sample coding in datagrid as such.

This is for testing
multiline
option display in
datagrid
<blank spaces>using asp.net

any idea.
Hope you are changing the line feeds from vbCrLf to <br/> .

If you done that too, then I guess posting your code might be helpful in solving the problem.
May 18 '07 #9
Problem resolved as the description in the blog
http://eblog.lichao.net/2007/05/21/p...ing/dotnet/59/
May 21 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Alex K. | last post: by
7 posts views Thread by Joel Finkel | last post: by
1 post views Thread by jeff maultby | last post: by
1 post views Thread by Aziz | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.