Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > wrapping text in datagrid

Reply
Thread Tools

wrapping text in datagrid

 
 
ireallyneedtoknow2007@yahoo.com
Guest
Posts: n/a
 
      11-11-2007
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>

 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      11-12-2007
On Nov 11, 7:36 pm, (E-Mail Removed) 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/...ble_3F00_.aspx

 
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
MS work around on text wrapping in a datagrid does not work TB ASP .Net 2 02-22-2006 10:34 PM
To stop text wrapping in an datagrid asp.net 2003 Dan ASP .Net 0 02-25-2005 06:34 AM
wrapping text in a datagrid cell Roy H. Berger ASP .Net Datagrid Control 2 05-18-2004 01:56 PM
datagrid - Control Wrapping G. Dean Blake ASP .Net 2 05-07-2004 01:03 AM
How to turn wrapping off for datagrid columns Scott ASP .Net 1 01-08-2004 12:07 AM



Advertisments