No Control over Grid or Column Widths in a GridView with displaying XML data

No matter which properties I try to adjust, my gridview extends well past  the page width boundary of 988px, I am trying to set.

My application is reporting on changes made to an Access DB which I am storing in an XML file.

There are 8 columns in my Grid but the ones that, my guess, could be causing the problem are OldValues and NewValues.

I am not parsing the data in these columns because there are many tables involved and I just want to have a simple audit trail of

what changes were made to any of the tables.

Obviously, these two columns are variable in length  and in some cases are close to 1,500 characters in length.

This problem occurs both in IE (7) and Firefox (2.0) although it is more pronounced in Firefox. 

For example,  the Gridview extends 2 ½ screen widths in FF and  1 ½ widths in IE.

If, however, a page is rendered where there rows involved do not have long character counts in their OldValues/NewValues columns,

the grid will render to 988px.

I have a css Stylesheet that tries to set the screen width to 988px.

I’ve tried setting the whole Gridview to 988 px , setting the individual template labels to specific widths.

But no matter what I do, nothing seems to alter the rendering of the page.

Anyone have any ideas how I can control the width of the Gridview and keep it to a maximum of 988px?

 

Here is the source code involved:

 

StyleSheet.css

body { background: White;
    font-family: Sans-Serif,serif;
    font-size: 11pt;
    width:988px;
    text-align:left; table-layout:fixed;
    margin: auto;
}

GridView

         <asp:GridView AutoGenerateColumns="False" ID="GridView1" runat="server"
         CssSelectorClass="PrettyGridView"
         DataSourceID="XmlDataSource1" Style="position: relative"
         Caption="Table Changes" CaptionAlign="Top"
         AllowPaging="True" AllowSorting="True" Font-Bold="False" PageSize="6">
             <Columns>
                 <asp:TemplateField HeaderText="Table Name">
                     <ItemTemplate>
                        <asp:Label ID="Label5" runat="server"
                        Text='<%# XPath("tablename")%>'> </asp:Label>
                      </ItemTemplate>
                     <ItemStyle Wrap="True" />
                 </asp:TemplateField>             
                 <asp:TemplateField HeaderText="Table Key Value">
                     <ItemTemplate>
                        <asp:Label ID="Label5" runat="server"
                        Text='<%# XPath("tablekeyvalue")%>'> </asp:Label>
                      </ItemTemplate>
                     <ItemStyle Wrap="True" />
                 </asp:TemplateField>
                 <asp:TemplateField HeaderText="Old Values">
                     <ItemTemplate>
                        <asp:Label ID="Label6" runat="server"
                        Text='<%# XPath("oldvalues")%>' > </asp:Label>
                      </ItemTemplate>
                     <ItemStyle Wrap="False" />
                 </asp:TemplateField>
                 <asp:TemplateField HeaderText="New Values">
                     <ItemTemplate>
                        <asp:Label ID="Label7" runat="server"
                        Text='<%# XPath("newvalues")%>'> </asp:Label>
                      </ItemTemplate>
                     <ItemStyle Wrap="False" />
                 </asp:TemplateField>               
                 <asp:TemplateField HeaderText="Updated By">
                     <ItemTemplate>
                         <asp:Label ID="Label2" runat="server"
                         Text='<%# XPath("username")%>'></asp:Label>
                     </ItemTemplate>
                     <ItemStyle Wrap="False" />
                 </asp:TemplateField>
                 <asp:TemplateField HeaderText="Update Date">
                     <ItemTemplate>
                         <asp:Label ID="Label3" runat="server"
                         Text='<%# XPath("auditdate")%>'></asp:Label>
                     </ItemTemplate>
                     <ItemStyle Wrap="False" />
                 </asp:TemplateField>
                 <asp:TemplateField HeaderText="Update Time">
                     <ItemTemplate>
                        <asp:Label ID="Label4" runat="server"
                        Text='<%# XPath("audittime")%>'> </asp:Label>
                      </ItemTemplate>
                     <ItemStyle Wrap="False" />
                 </asp:TemplateField>
                 <asp:TemplateField HeaderText="Comments">
                     <ItemTemplate>
                        <asp:Label ID="Label5" runat="server"
                        Text='<%# XPath("comments")%>'> </asp:Label>
                      </ItemTemplate>
                     <ItemStyle Wrap="True" />
                 </asp:TemplateField>                
             </Columns>
             <PagerStyle Font-Bold="False" />
        </asp:GridView>

XMLDataSource:

   <asp:XmlDataSource ID="XmlDataSource1" runat="server"
        DataFile="~/App_Data/XMLAuditFile.xml" XPath="//dbchanges"
        TransformFile="~/TMMaint/SortAuditFile.xsl" >
   </asp:XmlDataSource>

   

SortAuditFile.xsl

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes" />
  <xsl:strip-space elements="*"/>
  <xsl:template match="*">
    <xsl:copy>
      <xsl:for-each select="@*">
        <xsl:copy/>
      </xsl:for-each>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>
  <xsl:template match="dbaudit">
    <xsl:copy>
      <xsl:for-each select="@*">
        <xsl:copy/>
      </xsl:for-each>
      <xsl:for-each select="dbchanges">
        <xsl:sort select="auditdate" order="descending"/>
        <xsl:sort select="audittime" order="descending"/>        
        <xsl:apply-templates select="."/>
      </xsl:for-each>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
 
0
DannyDep
5/18/2007 6:15:27 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

3 Replies
1214 Views

Similar Articles

[PageSpeed] 57
Get it on Google Play
Get it on Apple App Store

0
dribar
5/18/2007 8:16:12 PM

Bump

0
DannyDep
5/19/2007 1:50:20 AM

Try applying a css to your label.

<asp:TemplateField HeaderText="Old Values">
                     <ItemTemplate>
                        <asp:Label ID="Label6" runat="server" CSSClass="clsFixedWidth"
                        Text='<%# XPath("oldvalues")%>' > </asp:Label>
                      </ItemTemplate>
                     <ItemStyle Wrap="False" />
                 </asp:TemplateField>

 

the style

.clsFixedWidth{

 width:200px;

overflow:auto; 

You could try the other overflow values "scroll" and "hidden" and see what fits your needs.


Regards,
Prashant


Dont forget to click "Mark as Answer" on the post that helped you.
0
Prashant
5/19/2007 3:42:23 AM
Reply:

Similar Artilces:

Data presentation control in another Data presentation control
 Hello,I want to make a menu with datalist or gridview control.Basically,the menu will be like this,Categories     Sub Categories.For example, for COMPUTING category there will be NOTEBOOKS DESKTOPS etc.There will be a image for CATEGORIES and linkbuttons with Subcategories.If I put a datalist inside a datalist and a link button inside the second datalist visually it satisfies my need.However,CommandArguments come from database to linkbutton.Andwhen one of these command buttons is cliked it must go to proper page.I dont know how to wrie an event_handler ,specifically, for...

How can I control the width of a column in the GridView control.
From searching I see mention of ways to do it before the controls are bound. Is there a simpler way? If not, could someone explain to me how I need to go about it?Here is the code: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id"        DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display."        OnSelectedIndexChanged="GridView1_SelectedIndexChanged">   &nbs...

Display only Columns that have Data in GridView Control
Good evening to the community, thanks for the help that ever provideThe situation is the following:I'm working in a application that have like 50 columns in the Database that represents Earning Codes for employees, but most of the times only 10 are used.What if something can be done to only display in the GridView Control the columns that the value is different than Null. Thanks for any lead evick   If you set the gridview to auto create the columns based on the datasource then when selecting data from the db only return the columns that have data in them. aspro Please m...

Bind Data to an Image Control not in a Data Presentation Control
I've been searching for two days but I don't really know what to search for.I'm making a site for a photographer.  The Default.aspx page displays Albums by showing a title, image and description from the database table Albums. Click an album to view the contents and it passes the QueryString which is AlbumName.  The ViewAlbum.aspx page uses the QueryString to display an UpdatePanel holding a Large Image and a Repeater full of dynamically filled ImageButtons for thumbs.  Both are from the database table Photos and are retrieved using an ObjectDataSource. Click the ...

i have work on gridview control.in that i have 3columns.name as subject,bookname,link. in this some link column data are very large.according to that data(no spaces in that data)gridview has changed.i
hi,i have work on gridview control.in that i have 3columns.name as subject,bookname,link. in this some link column data are very large.according to that data(no spaces in that data)gridview has changed.i want display half of the data and remaining display like this.(ex:http://ww.yahoo.com...........).how can i display like this,and one more thing is always the column size will constant. Try something like this: <asp:templatefield headertext="Link"> <itemtemplate> <asp:hyperlink id="HyperLink1" runat="server" navigateurl='<...

Update other controls after a Postback has fired from another control - eg insert data
Hi This is a slight modification to the personalweb asp.net template which shipped with VS2005 I have a web form - linked to a master with two content placeholders left and right: #1 In the left i have a formview containing a textbox + button - and a datasrouce object with an insertmethod - this calls a method to insert the textbox data into table albums: #2 In the right  i have a gridview which has a datasource this has a selectmethod which calls a select method from table albums. Because i am using a maser template with two content placeholders i cannot use the same ObjectD...

Trying to use the FAQ " Sorting and paging in the GridView control when not using data source controls "Sorting and paging in the GridView control when not using..."
and I am not getting the results I had hoped for.  I keep getting a "Compiler Error Message: CS0123: No overload for 'AdhocJobGridView_PageIndexChanged' matches delegate 'System.EventHandler'".   Here is my event handling... protected void AdhocJobGridView_PageIndexChanged(object sender, GridViewPageEventArgs e){ try { AdhocJobGridView.DataSource = wsBaseInfoArray; AdhocJobGridView.PageIndex = e.NewPageIndex; AdhocJobGridView.DataBind(); }catch (Exception ex) {throw ex; }   Here is my aspx... <asp:GridView ID="AdhocJobGridView...

ajax control in data presentation controls
can i add ajax controls (MaskedEdit) to presentation controls (dataGrid, dataForm)?? Hi,of course. But keep in mind that those controls are extenders, so you append them to an existing control. Just convert your GridView / DetailsView-fields into templated fields and add the extender you'd like to use to the controls.RegardsMarco Buerckel Don't forget to mark posts that were helpful as answers. Actually, if you looked at the source code for the Masked Edit Extender, you'd see  [TargetControlType(typeof(TextBox))]Meaning, targeting any control type other than textboxes...

Is there any way to control the width of the Gridcolumn when the data is present and not present
I would like to know if there is any way you can control the gridview column width. Thanks in advance. Digish Hi,   try these link http://www.eggheadcafe.com/community/aspnet/17/10004157/setting-gridview-column-w.aspx http://msdn.microsoft.com/en-us/library/ms178296(VS.80).aspxBabaIf this post was useful to you, please Don't forget to click "Mark as Answer". Thanks You.:-)...

Display Data in Table or Data Grid Control horisontaly
How do I put the data from DataReader or DataSet to DataGrid or Table control. Let's say I have pictures to be displayed (40 pictures) I need to to display 2 pictures per row and 10 per page and have 4 pages of the pictures. How do I do that. Have a look at the Datalist control - you can set the number of rows or columns to be displayedIf it was easy, everybody would be doing it....

Is there a control that offers the same data presentation as a GridView, but allows users to copy and paste many rows/columns at once?
 Hi Is there a control that offers the same data presentation as a GridView, but allows users to copy and paste many rows/columns at once onto the grid? What I mean is some grid that 's as flexible as MS Excel grid for example.  Any suggestions will be very much appreciated.E The Repeater control is a highly customisable data presentation controlRohin.NET developerNever trust a computer you can't throw out a window. - Steve WozniakPlease remember to click on 'Mark as answer', if this post helped you......

Symbols from XML file not showing up when XML is displayed through GridView control
The symbols from my XML file are not showing up when I display the file through the GridView control I tried defining them in the DTD<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE whatsnew [<!ENTITY eacute "<symbol name='eacute' />"><!ENTITY trade "<symbol name='trade' />"><!ENTITY reg "<symbol name='reg' />">]>I've been using them as &eacute; &trade; and &reg; respectivelyWhat is the problem?    Hi, Are you using the xmlcontro...

Menu control is displaying behind Gridview control
I have placed a menu control just above the gridview control but when i click the menu control it displaysome of the menu options and rest of the menu options display behind the gridview.Is there anyway any option which make the menu to display over gridview.Mark as answer if anybody's post has helped you Typically the ZIndex will control that: http://www.w3schools.com/Css/pr_pos_z-index.aspDavid Kiffhttp://DavidKiff.co.uk-- "Mark As Answer" If my reply helped you --...

data presentation controls (how to call the individual controls)
Hi please help me.,i have this question., example i create a site with one control, like textbox. when i double click on the white page, the page load event, in the intellisense, the textbox is visible, but when a formview with a textbox inside, in the same page load event, intellisense, the textbox is not available. how can i do the simple intellisense calling where the textbox is just outside a data presentation control like formview. i mean by this intellisense calling is in VB code view., thanks JFRBPH12™  The textbox is within the formview then you can find it like this...

gridview control in another gridview control
Hi ia have a questioni have a gridview control which contains button in one colum.now my question is i need another gridview to be placed in the  first gidviewso that when i click on the button the second gridview will populate the data.now my question is how to place second gridview in first gridview.or is there any approach like first grid itself acting as parent and child.please help me  Hi sirikalavalapalli:                I think nested gridview will help you. Check this link and it will show you how to do it.                http://msdn2.microsoft.com/en-us/library/aa992038(VS.80).aspx                Let me know if I have misunderstood what you mean. Thanks. KarlClick "Mark as Answer" on the post if the answers helpClick "Unmark as Answer" if you need more directionThank you for your cooperation Hi Siri,      Take a grid view with two template fields.      Place a button in first template.And Place GridView in Second Template.     This will complete your work.     This will help you completing your work.Still If you want I can send you code..           Lokanadham M.Hyderabad. Hi LokanadhamTh...

-- Need to Display data in two GridView controls, but second one could not be displayed?
Dear all, I wrote a code segment to display data in two GridView controls one by one as below. The first one is displayed ok. But, the second one is not displayed. Did I miss anything?         ads.DataFile = "~/App_Data/color_match_live.mdb"                ads.SelectCommand = "SELECT COUNT(*) FROM [tech_mstr] WHERE [month] = ?"        ads.SelectParameters.Add("month", sel_month)        Di...

Gridview control for column width
Can someone tell me what control I need for setting column width at the size that I want? If you have any examples that would be a great help.   Thanks! Try setting ControlStyle-Width to the value you want Jeev~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~If you get the answer to your question, please mark it as the answer. Wich tag does this go under? asp bound? for that one column? Here is what I tried and got the same width on the grid. Does this need to be used in my skin?<asp:BoundField HeaderText="OffensiveTeam" DataField="offense" ItemStyle-HorizontalAl...

GridView control column width
I've been working this for awhile, and it's driving me insane very quickly. Creating a specific width for the columns in a GridView control seems to be a matter of much contention, and it's contending with me. To sum up what I've done: I've tried this with both a TemplateField and a BoundField. Using a BoundField, I created an ItemStyle tag with Width="200px". The text in the label rendered is not sufficient to cause a problem, but there was no change. I tried setting it in the code-behind with myGridView.Columns[0].ItemStyle.Width = 200; This also produced...

Gridview control not displaying my data
My gridview control appears set correctly.  Nothing displays at run time. I am using a sqldatasource (sqlserver).  At design time, with the wizard, the sql statments are executed  via the TEST Query Button then data is always returned.  No error messages are displayed.  No Gridview either. Imports System.DataPartial Class _DefaultInherits System.Web.UI.Page     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load         GridView3.DataBind()     End Su...

Display data in GridView Control
How can I group the same data in a field inside a gridview. The data is in a table on the db. Ex: Customers, Orders I dont wanto to display the same customer more than one time Customer1 - Order1, Order2, Order3.... Customer2 - Order1, Order2, Order3..... Can this be posible using a gridview?   use a nested gridview inside an itemtemplate where can I find a example for this? Thanks Are you binding to a SQL DataSource? If you were then it'd be a matter of using "Group By..." in your query to get rid of those duplicates.This is the part where I ...

Issue with Template Columns & Bound Columns while updating the data in a GridView control
Hi, I'm facing the below problem (In general, ObjectDataSource is driving me crazy ! ) I have a simple gridview control and an ObjectDataSource is used to populate the grid. I'm trying to update a row and the corresponding tableadapter methods & stored procedure are in place. Each row has 2 checkboxes and 2 textboxes in edit mode. When the change the values in edit mode and hit update, the checkbox values changed are saved into the Database properly, whereas the textbox values are not being saved. If the textbox column is a bound column then the column is updated with <NULL> in Database. If I change it to a template column, then no update is done; the old value is retained in Database. So, in none of the cases I get the desired result. What am I missing here? I have NO code in any of the events like GridView_RowUpdating etc.. and I intend not to have any. This is pretty straightforward update. Please help.  Thanks Jai Hi Jai, Since there are only 2 columns updated, I suggest you check the UPDATE statement in your Update method of ObjectDataSource. The code to update the other 2 columns might be missing. You can try to add some breakpoints in the Update method, step through it to see if every parameter and value has been added properly. If you're using a SQL Server database, you can also start SQL Profiler to get a trace to see what is actually being executed on the server.Sincerely,Kevin YuMicrosoft Online Community SupportPlease remember to cli...

Getting the control id of a control inside gridview control
 uhmm.. a little bit confusing regarding my subject because i dont know how to say it...by the way my problem is how can i get the id of a control (e.g. textbox) inside the gridview... and the textbox is in the templatefield... is there any way i can get its id??  hoping i could get a reply as soon as possible... Regards,MhaeyPlease remember to click “Mark as Answer” on the post that helps you.. =) What do you want's to do by getting the id of the Text box? Do you want's to find particular Textbox with certain id ? Kamran ShahidSr. Software Engineer(MCP,MCAD.net,MCSD.net,MCTS,MCPD.net[web])Netprosys Inc.www.netprosys.comRemember to click "Mark as Answer" on the post that helps U  hi, you can use the find control method....if suppose the textbox is in the first column TextBox txt = Gridview1.Rows[0].Cells[0].FindControl("Textboxname") as TextBox; thanks, rajiv You can do so by using row data bound event and e.row.findcontrol("textbox1").ClientID, where textbox1 is the id of the textbox I agree wihth Kamran Shahid. What do you want to do by getting id?Sridhar if i get the id i will put some value into it... is that possible...for some reasons... instead of putting codes into the client side.. i would put it to the server side... but i cant get the id of it...  Regards,MhaeyPlease remember to click “Mark as Answer” on the post that helps you.. =) Hi darkcat02 , See my sample,   pr...

Edit data with GridView Control ? or another control ? help
I use GrivView in ASP.Net 2.0 to show data from DataTable. And i want to edit some fields in some rows. How can I do it? If i touch EDIT button - all columns, which have ReadOnly=false, switch into EDIT mode. But I want, that in first raw I can edit 2,3 column and in second row only 3 column. How can I do it ? ...

Visibility control of Panel control and its affect on data controls
Thought I would toss this out here this morning and perhaps someone else had run across the same issue and had found a good way to accomplish what I want. First let me state what I'm attempting to do and the problem that I've run into.  GridView1 has a collection of rows in a SQL table that I want to present to the user. I've provided them the options of sorting and selecting only from the GridView control.  Orgionally, I had created a detail view that was being presented in Edit mode and then customized the layout of the edit item template to suit my needs.&nbs...

Web resources about - No Control over Grid or Column Widths in a GridView with displaying XML data - asp.net.presentation-controls

List of mammals displaying homosexual behavior - Wikipedia, the free encyclopedia
For these mammals, there is documented evidence of homosexual behavior of one or more of the following kinds: sexual behavior , courtship , affection ...

Facebook Displaying Page Insights On Page Admins’ Personal Pages?
Some Facebook page administrators are seeing modules on their personal pages displaying page insights ad, campaign , and like totals for pages ...

Facebook Displaying Unread Messages from Pages in a New Updates Module
Facebook is displaying a new “Updates” sidebar module which shows some users unread messages sent to them by Pages. Users will see the Updates ...

Don Lemon Holds Up Sign Displaying the N-Word, Uncensored, on Air CNN Live - YouTube
Don Lemon Holds Up Sign Displaying the N-Word, Uncensored, on Air Lemon held up a Confederate flag first before holding up the sign. He asked, ...

Hazelwood coal mine fire: Morwell residents displaying symptoms similar to cigarette smokers, expert ...
An expert says some locals near Victoria's Hazelwood mine fire have symptoms similar to cigarette smokers.

Police accused of displaying fake G20 weapons
Toronto's top police officer misled the public by displaying fake weapons used in a medieval-themed role-playing game to help justify their actions ...

No charges for U.S. host for displaying high-capacity magazine on TV
NBC television journalist David Gregory won't face charges for displaying a high-capacity ammunition magazine on his "Meet the Press" news program ...

Jays' Escobar suspended three games for displaying slur
Toronto Blue Jays shortstop Yunel Escobar has been suspended three games for displaying a homophobic slur on his eye-black during a game on Saturday. ...

Google Play Store now displaying age-based ratings
We reported back in May that Google was adding age-based ratings to all apps in the Play Store as determined by the International Age Rating ...

Apple displaying Ferraris & other cars at WWDC hinting at CarPlay announcements
... 2014 Filed under: AAPL Company , iOS Continue reading more about AAPL Company and iOS at 9to5Mac . What do you think? Discuss "Apple displaying ...

Resources last updated: 3/20/2016 6:35:22 PM