wrapping text in datagrid

Discussion in 'ASP .Net' started by ireallyneedtoknow2007@yahoo.com, Nov 11, 2007.

  1. Guest

    hello I am trying to wrap the text in the contact_email cell of a
    datagrid in asp.net 2.0 and tried many variations of the code below.
    the asp:TemplateColumn HeaderText="Email" wraps as expected but I
    cannot get the asp:BoundColumn Visible="False"
    DataField="contact_email" field to wrap at all.

    thanks for any suggestions

    public void myDataGrid_PreRender(object sender, System.EventArgs e)
    {
    myDataGrid.Columns[5].ItemStyle.Width = 3;
    myDataGrid.Columns[5].ItemStyle.Wrap = true;
    }


    <asp:datagrid id="myDataGrid" style="Z-INDEX: 100; LEFT: 20px;
    POSITION: absolute; TOP: 260px"
    OnItemDataBound="myDataGrid_ItemDataBound" runat="server"
    OnPageIndexChanged="myDataGrid_PageIndexChanged"
    OnDeleteCommand="myDataGrid_DeleteRow"
    OnEditCommand="myDataGrid_EditCommand"
    OnCancelCommand="myDataGrid_CancelCommand"
    OnUpdateCommand="myDataGrid_UpdateCommand" AllowSorting="True"
    AllowPaging="True" Font-Size="X-Small"
    Font-Names="Verdana" ForeColor="Black" GridLines="None"
    CellPadding="2" BackColor="LightGoldenrodYellow"
    BorderWidth="1px" BorderColor="Tan" Width="900px" Height="304px"
    AutoGenerateColumns="False" OnPreRender="myDataGrid_PreRender">
    <FooterStyle BackColor="#BBD7BB"></FooterStyle>
    <SelectedItemStyle ForeColor="GhostWhite" BackColor="DarkSlateBlue"></
    SelectedItemStyle>
    <AlternatingItemStyle BackColor="PaleGoldenrod"></
    AlternatingItemStyle>
    <HeaderStyle Font-Bold="True" BackColor="Tan"></HeaderStyle>
    <Columns>
    <asp:BoundColumn DataField="Sender" ReadOnly="True"
    HeaderText="Sender" ItemStyle-Wrap=true></asp:BoundColumn>
    <asp:BoundColumn DataField="Receiver" ReadOnly="True"
    HeaderText="Receiver" ItemStyle-Wrap=true></asp:BoundColumn>
    <asp:BoundColumn DataField="Doc_Type" ReadOnly="True"
    HeaderText="Doc Type" ItemStyle-Wrap=true></asp:BoundColumn>
    <asp:BoundColumn DataField="Route" ReadOnly="True"
    HeaderText="Route" ItemStyle-Wrap=true></asp:BoundColumn>
    <asp:BoundColumn Visible="False" DataField="contact_email"
    ReadOnly="True" HeaderText="Email" ItemStyle-Wrap=true>
    </asp:BoundColumn>
    <asp:TemplateColumn HeaderText="Email" ItemStyle-Width="10px"
    FooterStyle-Width="10px" HeaderStyle-Width="10px"
    ItemStyle-Wrap=true FooterStyle-Wrap=true HeaderStyle-Wrap=true>
    <ItemTemplate>
    <%# DataBinder.Eval(Container.DataItem, "contact_email") %>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox id=TextBox1 runat="server" Wrap=True
    TextMode=MultiLine Width=300 Text='<%#
    DataBinder.Eval(Container.DataItem,"contact_email") %>'>
    </asp:TextBox>
    </EditItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn HeaderText="Duplicate" ItemStyle-Wrap=true >
    <ItemTemplate>
    <asp:CheckBox id=chk runat="server" AutoPostBack="true"
    OnCheckedChanged="oncheckchanged" Checked='<
    %#IsCheck(DataBinder.Eval(Container.DataItem, "Duplicate")) %>'>
    </asp:CheckBox>
    </ItemTemplate>
    </asp:TemplateColumn>

    <asp:EditCommandColumn UpdateText="Update" HeaderText="Edit"
    CancelText="Cancel"
    EditText="Edit" ItemStyle-Wrap=true></asp:EditCommandColumn>
    <asp:ButtonColumn Visible="False" Text="Delete" HeaderText="Delete"
    CommandName="Delete"></asp:ButtonColumn>
    <asp:TemplateColumn HeaderText="Delete">
    <ItemStyle Wrap=true />
    <ItemTemplate>
    <asp:linkbutton id="btnDelete" CommandName="Delete"
    OnClick="setviewstate" runat="Server" Text="Delete"
    ForeColor="#000000" />
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    <PagerStyle HorizontalAlign="Center" ForeColor="DarkSlateBlue"
    BackColor="PaleGoldenrod" Mode="NumericPages"></PagerStyle>
    </asp:datagrid>
     
    , Nov 11, 2007
    #1
    1. Advertising

  2. On Nov 11, 7:36 pm, wrote:
    > hello I am trying to wrap the text in the contact_email cell of a
    > datagrid in asp.net 2.0 and tried many variations of the code below.
    > the asp:TemplateColumn HeaderText="Email" wraps as expected but I
    > cannot get the asp:BoundColumn Visible="False"
    > DataField="contact_email" field to wrap at all.
    >
    > thanks for any suggestions
    >
    > public void myDataGrid_PreRender(object sender, System.EventArgs e)
    > {
    > myDataGrid.Columns[5].ItemStyle.Width = 3;
    > myDataGrid.Columns[5].ItemStyle.Wrap = true;
    >
    > }
    >
    > <asp:datagrid id="myDataGrid" style="Z-INDEX: 100; LEFT: 20px;
    > POSITION: absolute; TOP: 260px"
    > OnItemDataBound="myDataGrid_ItemDataBound" runat="server"
    > OnPageIndexChanged="myDataGrid_PageIndexChanged"
    > OnDeleteCommand="myDataGrid_DeleteRow"
    > OnEditCommand="myDataGrid_EditCommand"
    > OnCancelCommand="myDataGrid_CancelCommand"
    > OnUpdateCommand="myDataGrid_UpdateCommand" AllowSorting="True"
    > AllowPaging="True" Font-Size="X-Small"
    > Font-Names="Verdana" ForeColor="Black" GridLines="None"
    > CellPadding="2" BackColor="LightGoldenrodYellow"
    > BorderWidth="1px" BorderColor="Tan" Width="900px" Height="304px"
    > AutoGenerateColumns="False" OnPreRender="myDataGrid_PreRender">
    > <FooterStyle BackColor="#BBD7BB"></FooterStyle>
    > <SelectedItemStyle ForeColor="GhostWhite" BackColor="DarkSlateBlue"></
    > SelectedItemStyle>
    > <AlternatingItemStyle BackColor="PaleGoldenrod"></
    > AlternatingItemStyle>
    > <HeaderStyle Font-Bold="True" BackColor="Tan"></HeaderStyle>
    > <Columns>
    > <asp:BoundColumn DataField="Sender" ReadOnly="True"
    > HeaderText="Sender" ItemStyle-Wrap=true></asp:BoundColumn>
    > <asp:BoundColumn DataField="Receiver" ReadOnly="True"
    > HeaderText="Receiver" ItemStyle-Wrap=true></asp:BoundColumn>
    > <asp:BoundColumn DataField="Doc_Type" ReadOnly="True"
    > HeaderText="Doc Type" ItemStyle-Wrap=true></asp:BoundColumn>
    > <asp:BoundColumn DataField="Route" ReadOnly="True"
    > HeaderText="Route" ItemStyle-Wrap=true></asp:BoundColumn>
    > <asp:BoundColumn Visible="False" DataField="contact_email"
    > ReadOnly="True" HeaderText="Email" ItemStyle-Wrap=true>
    > </asp:BoundColumn>
    > <asp:TemplateColumn HeaderText="Email" ItemStyle-Width="10px"
    > FooterStyle-Width="10px" HeaderStyle-Width="10px"
    > ItemStyle-Wrap=true FooterStyle-Wrap=true HeaderStyle-Wrap=true>
    > <ItemTemplate>
    > <%# DataBinder.Eval(Container.DataItem, "contact_email") %>
    > </ItemTemplate>
    > <EditItemTemplate>
    > <asp:TextBox id=TextBox1 runat="server" Wrap=True
    > TextMode=MultiLine Width=300 Text='<%#
    > DataBinder.Eval(Container.DataItem,"contact_email") %>'>
    > </asp:TextBox>
    > </EditItemTemplate>
    > </asp:TemplateColumn>
    > <asp:TemplateColumn HeaderText="Duplicate" ItemStyle-Wrap=true >
    > <ItemTemplate>
    > <asp:CheckBox id=chk runat="server" AutoPostBack="true"
    > OnCheckedChanged="oncheckchanged" Checked='<
    > %#IsCheck(DataBinder.Eval(Container.DataItem, "Duplicate")) %>'>
    > </asp:CheckBox>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    >
    > <asp:EditCommandColumn UpdateText="Update" HeaderText="Edit"
    > CancelText="Cancel"
    > EditText="Edit" ItemStyle-Wrap=true></asp:EditCommandColumn>
    > <asp:ButtonColumn Visible="False" Text="Delete" HeaderText="Delete"
    > CommandName="Delete"></asp:ButtonColumn>
    > <asp:TemplateColumn HeaderText="Delete">
    > <ItemStyle Wrap=true />
    > <ItemTemplate>
    > <asp:linkbutton id="btnDelete" CommandName="Delete"
    > OnClick="setviewstate" runat="Server" Text="Delete"
    > ForeColor="#000000" />
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > </Columns>
    > <PagerStyle HorizontalAlign="Center" ForeColor="DarkSlateBlue"
    > BackColor="PaleGoldenrod" Mode="NumericPages"></PagerStyle>
    > </asp:datagrid>


    Look at this:

    http://community.sgdotnet.org/blogs...-GridView--_2D00_-Is-that-possible_3F00_.aspx
     
    Alexey Smirnov, Nov 12, 2007
    #2
    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. Mike Casey
    Replies:
    7
    Views:
    3,954
    Scott M.
    Dec 19, 2003
  2. PeteZ

    AdRotator and Text Wrapping

    PeteZ, Dec 30, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    408
    PeteZ
    Dec 30, 2004
  3. Dan
    Replies:
    0
    Views:
    470
  4. TB
    Replies:
    2
    Views:
    3,765
  5. Roy H. Berger

    wrapping text in a datagrid cell

    Roy H. Berger, May 18, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    174
    Eliyahu Goldin
    May 18, 2004
Loading...

Share This Page