help with datagrid

  • Thread starter Thread starter Alejandro Penate-Diaz
  • Start date Start date
A

Alejandro Penate-Diaz

I have a datagrid inside a table and I want to fix both (table and databrid)
width to 700, but when the content of datagrid is too large the width
increases automatically sometimes and sometimes not. Please need help with
that.
Thanks,
Alejandro.
 
Alejandro Penate-Diaz said:
I have a datagrid inside a table and I want to fix both (table and
databrid) width to 700, but when the content of datagrid is too large the
width increases automatically sometimes and sometimes not. Please need help
with that.

Have you tried setting Width="700px" on the DataGrid? Or Width="100%"?

John Saunders
 
yes I tried width="700px" for the datagrid and each column (5 columns) are
width="140px" and property "wrap" set to true to each column and <td>. but
this is just not working, sometimes it does but sometimes not, it dependes
on the text on the column, for example if the text is "Microsoft Certified
Application Developer" it works ok and text is wraped, but if the text is
"ASP.NET.Unleashed.2nd.Edition"it doesnt work.

Alejandro.
 
Alejandro Penate-Diaz said:
yes I tried width="700px" for the datagrid and each column (5 columns) are
width="140px" and property "wrap" set to true to each column and <td>. but
this is just not working, sometimes it does but sometimes not, it dependes
on the text on the column, for example if the text is "Microsoft Certified
Application Developer" it works ok and text is wraped, but if the text is
"ASP.NET.Unleashed.2nd.Edition"it doesnt work.

Your problem is that you need some kin of wordspliting utillity. When you
have serval words the browser can wrap the contents like you want but with
very long words it has to take a decission. Hide the overflown text or
expand the table....The browser does the last.

You could set CSS overflow: hidden to hide the text but do you really want
that? You can´t make the browser split words and insert "-"..

Anders
 
thans, that's exactly my problem. I have seen log words with "-" been
splited automaticaly but with "." doesnt work. Can I hide the extra text
without using CSS? I dont mind hiding the extra text because there is an
Edit button that can be used to see the whole text.

Thanks,
Alejandro.
 
thans, that's exactly my problem. I have seen log words with "-" been
splited automaticaly but with "." doesnt work. Can I hide the extra text
without using CSS? I dont mind hiding the extra text because there is an
Edit button that can be used to see the whole text.

Why wouldnt you use CSS? Target IE 3+? Anyway if you choose css look eg
here; http://www.quirksmode.org/css/overflow.html

If you dont want css you are on you own eg with javascript to pass the
innerHtml in the TD and eg. cut off all leters where innerHTML.legth > eg
20 letters. Dont know. Go for css if possible.

Anders
 
I will try css but I just dont know how to do it. if you want to take a look
below is my code:



<TABLE id="Table1" style="WIDTH: 700px; overflow: scroll" height="100%"
cellSpacing="1" cellPadding="1" width="700"
border="0">
<TR>
<TD style="HEIGHT: 4px"><uc1:header id="Header1"
runat="server"></uc1:header></TD>
</TR>
<TR>
<TD height="10">
<uc1:subheader id="Subheader1" runat="server"></uc1:subheader></TD>
</TR>
<TR style="BACKGROUND-COLOR: white; overflow: scroll">
<TD style="overflow: scroll" vAlign="top" align="left" width="700"
bgColor="#000000"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
<P>
<asp:HyperLink id="HyperLink1" runat="server"
NavigateUrl="logs.aspx" ForeColor="#FFFF80">Logs</asp:HyperLink></P>
<P><asp:dropdownlist id="sectionDDL" runat="server"
AutoPostBack="True">
<asp:ListItem Value="Sections"
Selected="True">Sections</asp:ListItem>
</asp:dropdownlist><asp:dropdownlist id="subsectionsDDL"
runat="server" AutoPostBack="True" Visible="False"></asp:dropdownlist></P>
</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
<asp:DataGrid id="DataGrid1" runat="server" Visible="False"
HorizontalAlign="Left" Width="700px"
AutoGenerateColumns="False" ItemStyle-Wrap="true"
ItemStyle-Width="140px">
<ItemStyle Font-Size="Smaller" Width="140px"
BackColor="#FFFFC0"></ItemStyle>
<HeaderStyle BorderStyle="Solid" BackColor="#C0C0FF"></HeaderStyle>
<Columns>
<asp:EditCommandColumn ButtonType="PushButton" UpdateText="Update"
CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
<asp:ButtonColumn Text="Delete" ButtonType="PushButton"
CommandName="Delete"></asp:ButtonColumn>
<asp:BoundColumn DataField="id" ReadOnly="True"
HeaderText="ID"></asp:BoundColumn>
<asp:BoundColumn DataField="url" HeaderText="Url"
ItemStyle-Wrap="true" ItemStyle-Width="140px"></asp:BoundColumn>
<asp:BoundColumn DataField="text" HeaderText="Text"
ItemStyle-Wrap="true" ItemStyle-Width="140px"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
<P align="center">&nbsp;</P>
</SPAN>
</TD>
</TR>
</TABLE>
 
I made it, thanks. just wrapped te datagrid between <div></div> and set
overflow:auto

Thanks,
Alejandro
 
I made it said:
overflow:auto

Yes sorry for not been more precise. The overflow applies to div as you
noticed.

Happy programming
Anders Jacobsen, Denmark
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top