I
ireallyneedtoknow2007
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>
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>