Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > gridview columns

Reply
Thread Tools

gridview columns

 
 
Fritz the Cat
Guest
Posts: n/a
 
      03-16-2007
Hi I have a long column of data.
I'd like that to wrap into 5 columns, like a newspaper article

how to do?
thanks



 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      03-16-2007
You need to split one column into 5 programmatically, put the result in a
datasource like a datatable and databind to the new datasource.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin


"Fritz the Cat" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi I have a long column of data.
> I'd like that to wrap into 5 columns, like a newspaper article
>
> how to do?
> thanks
>
>
>



 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      03-16-2007
On Mar 16, 8:23 am, "Fritz the Cat" <(E-Mail Removed)> wrote:
> Hi I have a long column of data.
> I'd like that to wrap into 5 columns, like a newspaper article
>


http://groups.google.com/group/micro...8b3716c0087a40

 
Reply With Quote
 
=?Utf-8?B?UGFydmF0aHkgUGFkbWFuYWJoYW4=?=
Guest
Posts: n/a
 
      03-30-2007

Hi,

If you need to bind your huge text content to some column in a data
control, then in that case, you cld possibly try this option.

Html source:

<asp:GridView ID="gvColWrap" runat="server" AutoGenerateColumns="false" >
<Columns>
<asp:BoundField HeaderText="Your Original contented"
DataField="contentOriginal" />
<asp:BoundField HeaderText="<td colspan=5>Your wraped contented</td>"
HtmlEncode="false" DataField="contentWraped" />
</Columns>
</asp:GridView>

The second column here splits the same huge text content on column one into
5 diffrent columns within the same column itself.

Code to bind data to control:

DataTable dt = new DataTable();
dt.Columns.Add("contentOriginal");
dt.Columns.Add("contentWraped");

DataRow dr = dt.NewRow();
dr[0] =" ------ Huge original text content ------";
dr[1] = "<td> huge content split 1 </td>" +
"<td> huge content split 2 </td>" +
"<td> huge content split 3 </td>" +
"<td> huge content split 4 </td>" +
"<td> huge content split 5 </td>";

dt.Rows.Add(dr);
gvColWrap.DataSource= dt;
gvColWrap.DataBind();

As long as you know where you need to split the text for your five
paragraphs, each of the split content has to be prefixed with "<td>" and
suffixed with "</td>".

the HTMLEncode property of this particular dataBoundField needs to be set to
false.
If you desire to have a header for this field that is as wide as all the 5
columns in that case, for the headertext prefix and suffix it with <td> and
</td> and use the colspan property as in the example above.

I hope this helps.

- Parvathy Padmanabhan

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
template columns and bound columns in gridview Vinki ASP .Net Web Controls 2 04-25-2007 04:22 PM
Align table columns with gridview columns Jacksm ASP .Net 2 11-21-2006 09:49 PM
database columns vs. gui columns and sorting ittay.dror@gmail.com Java 5 03-04-2006 10:48 AM
CSS columns problem - faux columns don't work henrybranson@hotmail.com HTML 4 11-24-2005 10:05 AM
convert rows to columns and columns to rows helpful sql ASP .Net 0 05-19-2005 06:03 PM



Advertisments