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

  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, Mar 16, 2007
    1. Advertisements

  3. Alexey Smirnov, Mar 16, 2007
  4. Fritz the Cat

    Guest Guest


    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" >
    <asp:BoundField HeaderText="Your Original contented"
    DataField="contentOriginal" />
    <asp:BoundField HeaderText="<td colspan=5>Your wraped contented</td>"
    HtmlEncode="false" DataField="contentWraped" />

    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();

    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>";

    gvColWrap.DataSource= dt;

    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
    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
    Guest, Mar 30, 2007
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.