gridview columns

Discussion in 'ASP .Net' started by Fritz the Cat, Mar 16, 2007.

  1. 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
     
    Fritz the Cat, Mar 16, 2007
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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
    >
    >
    >
     
    Eliyahu Goldin, Mar 16, 2007
    #2
    1. Advertising

  3. Alexey Smirnov, Mar 16, 2007
    #3
  4. 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
     
    =?Utf-8?B?UGFydmF0aHkgUGFkbWFuYWJoYW4=?=, Mar 30, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. helpful sql
    Replies:
    0
    Views:
    839
    helpful sql
    May 19, 2005
  2. Replies:
    5
    Views:
    621
  3. Replies:
    4
    Views:
    952
  4. Jacksm
    Replies:
    2
    Views:
    873
    Paul Chalekian
    Nov 21, 2006
  5. Vinki

    template columns and bound columns in gridview

    Vinki, Apr 25, 2007, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    906
    Vinki
    Apr 25, 2007
Loading...

Share This Page