GridView default column too small for description column from data

Discussion in 'ASP .Net' started by JB, Sep 19, 2009.

  1. JB

    JB Guest

    Hello
    I using ASP.NET and dragged a GridView who’s datasource is a DataSet
    onto the web page. One of the columns in the dataset is a description and
    one of the columns in the dataset holds comments. I dragged the GridView
    from the toolbox so all of the columns in the GridView are of the default
    size. The problem is that once I start paging thru the GridView sometimes
    the description column and/or the comments column in the datasource/dataset
    contain a lot more text than the default size of the GridView column when it
    was dragged onto the web page. Consequently when one of those description or
    comments columns full of data from the datasource/dataset populates the
    GridView it forces the corresponding Gridview column to expand beyond its
    default size thereby causing the GridView to crash. I have used “Wrap=trueâ€
    and changing the size properties but it doesn’t help. How can I change the
    GridView so that it will support the description and comments column when
    they are full of text?
    JB

    --
    JB
     
    JB, Sep 19, 2009
    #1
    1. Advertising

  2. JB

    JB Guest

    Re: GridView default column too small for description column from

    Mark

    When I saw crash that means in addition to the GridView expanding into
    and overlaying other controls on the web page, in addition the paging
    function no longer operates so if you click a page number at the bottom of
    the GridView the page does not change. Below is the markup:

    <asp:GridView ID="PGrid" AllowPaging="True" BorderStyle="Solid"
    OnPageIndexChanging="PGrid_PageIndexChanged" PageSize="5" Height="50px"
    Width="1100px"
    AutoGenerateColumns="False" runat="server"
    onrowdatabound="PGrid_RowDataBound" >
    <Columns>
    <asp:TemplateField HeaderText="PID#" SortExpression="PID">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox1" runat="server" Text='<%#
    Bind("PID") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label1" runat="server" Text='<%#
    Bind("PID") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText="C Type" SortExpression="CID">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox2" runat="server" Text='<%#
    Bind("CID") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label2" runat="server" Text='<%#
    Bind("CID") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText="Coming" SortExpression="Coming">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox3" runat="server" Text='<%#
    Bind("Coming") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label3" runat="server" Text='<%#
    Bind("Coming") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText="Going" SortExpression="Going">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox4" runat="server" Text='<%#
    Bind("Going") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label4" runat="server" Text='<%#
    Bind("Going") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText="Desc" SortExpression="Desc">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox5" Wrap="true"
    TextMode="MultiLine" runat="server" Text='<%# Bind("Pro") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label5" runat="server" Text='<%#
    Bind("Pro") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText="Comments"
    SortExpression="IComments">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox6" Wrap="true"
    TextMode="MultiLine" runat="server"
    Text='<%# Bind("IComments") %>'> </asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label6" runat="server" Text='<%#
    Bind("IComments") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText="C Date Time" SortExpression="C
    Date Time">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox7" runat="server" Text='<%#
    Bind("CDateTime", "{0:M-dd-yyyy}" ) %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label7" runat="server" Text='<%#
    Bind("CDateTime") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText="Dpatch Date Time"
    SortExpression="Dpatch Date Time">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox8" runat="server"
    Text='<%# Bind("DDateTime") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label8" runat="server" Text='<%#
    Bind("DDateTime") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText="R Date Time"
    SortExpression="R Date Time">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox9" runat="server"
    Text='<%# Bind("RDateTime") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label9" runat="server" Text='<%#
    Bind("RDateTime") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    </Columns>
    </asp:GridView>

    --
    JB


    "Mark Rae [MVP]" wrote:

    > "JB" <> wrote in message
    > news:...
    >
    > > Consequently when one of those description or comments columns full of
    > > data
    > > from the datasource/dataset populates the GridView it forces the
    > > corresponding
    > > Gridview column to expand beyond its default size thereby causing the
    > > GridView
    > > to crash.

    >
    > 1) Please define what you mean by "crash" - what *PRECISELY* happens...?
    >
    > 2) Please post the GridView's markup.
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    >
    >
     
    JB, Sep 21, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U3VyZXNo?=
    Replies:
    0
    Views:
    546
    =?Utf-8?B?U3VyZXNo?=
    Mar 2, 2004
  2. Martin
    Replies:
    0
    Views:
    494
    Martin
    Aug 4, 2004
  3. Keith G Hicks
    Replies:
    3
    Views:
    806
    Keith G Hicks
    Feb 18, 2008
  4. JB
    Replies:
    1
    Views:
    880
    Alexey Smirnov
    Sep 23, 2009
  5. Dag Sunde
    Replies:
    4
    Views:
    378
Loading...

Share This Page