HighTechTalks DotNet Forums  

wrapping text in datagrid

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss wrapping text in datagrid in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
ireallyneedtoknow2007@yahoo.com
 
Posts: n/a

Default wrapping text in datagrid - 11-11-2007 , 12:36 PM






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
  #2  
Old   
Alexey Smirnov
 
Posts: n/a

Default Re: wrapping text in datagrid - 11-12-2007 , 01:27 PM






On Nov 11, 7:36 pm, ireallyneedtoknow2... (AT) yahoo (DOT) com wrote:
Quote:
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 Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.