Results 1 to 30 of 30

Thread: [RESOLVED] Gridview Question Again

  1. #1

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Resolved [RESOLVED] Gridview Question Again

    When im populating my gridview exactly 10 data the design would be exact however, when no records found my gridview becomes bigger. How to set it exactly thesame ?

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Question Again

    Hello,

    Just so that we are on the same page, would it be possible for you to show a screen shot of what you are referring to?

    Gary

  3. #3

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Re: Gridview Question Again

    Sorry for the late postback . Anyway this is an example, take have a look on the image below thats what happen when below 10 records displayed in the gridview the header and columnds become huge so how am I able to fix the size of those headers and columns.
    Attached Images Attached Images  

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Question Again

    Hey,

    You are going to have to show us the ASPX markup, and any CSS that you are using?

    It could be that you can add the EmptyDataTemplate to the GridView to account for when this happens, but you must be fixing the width and height of the GridView somewhere, and this is why you are seeing what you are.

    Gary

  5. #5

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Re: Gridview Question Again

    This is my MARKUP code for my GridView.

    Code:
                    <asp:GridView ID="dgvRecords" runat="server" 
                        style="position:absolute; top: 210px; left: 351px; height: 374px; width: 433px;" 
                        AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" 
                        ForeColor="#333333" GridLines="None" Font-Names="Arial" 
                        Font-Size="8pt">
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <Columns>
                            <asp:BoundField DataField="BUS_CTRL_NO" HeaderText="Control No." />
                            <asp:BoundField DataField="BUS_NAME" HeaderText="Business Name" />
                            <asp:CommandField ShowSelectButton="True" />
                        </Columns>
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <EditRowStyle BackColor="#999999" />
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    </asp:GridView>
    And for populating my GridView this is how I done it:
    Code:
                Me.dgvRecords.DataSource = dtTable
                Me.dgvRecords.DataBind()
    []

  6. #6
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Gridview Question Again

    It is because of CellPadding="4"

    Remove it or give it as 1. This will fix your problem
    Please mark you thread resolved using the Thread Tools as shown

  7. #7

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Re: Gridview Question Again

    Nothing happen, still the same -sire

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Question Again

    Hello,

    It is because of what I said.

    Your GridView has a fixed width and height. When there is no data to be bound to the Grid, it still takes up all that space, and with nothing to fill it with, it looks the way you showed in the screen shot.

    Try adding the EmptyDataTemplate to the GridView, with an appropriate message, and see if that helps.

    Gary

  9. #9

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Re: Gridview Question Again

    Is this right ? If its right then I choose the PageTamplate and nothing happen. It will return into emptytemplate.
    Attached Images Attached Images  

  10. #10
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Question Again

    Hey,

    What you are doing there is switching between the EmptyDataTemplate and the PagerTemplate for the purpose of editing those templates. Choose the EmptyDataTemplate, and then put "something" into it. How about a label, saying that there wasn't any data returned.

    Gar

  11. #11

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Re: Gridview Question Again

    How to add a label into EditTemplate ? Can't drag anything there .

  12. #12
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Question Again

    Hello,

    Are you referring to the EditItemTemplate within a TemplateField of your GridView?

    Gary

  13. #13

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Re: Gridview Question Again

    Yeep, If I'm not mistaken all I need to do is just like post #9. Then I noticed that theres a transparent box beside the panel so I'm trying to drag a label there but it doesn't work. So where am I going to add that label.

  14. #14
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Question Again

    Hello,

    I have just tested what I thought was the case, and it is.

    You simply select EditItemTemplate from the DropDownList, for the column you want to edit, and click and drag controls in.

    I don't know why this isn't working for you.

    You can also edit it in the ASPX source code for the page.

    Gary

  15. #15

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Re: Gridview Question Again

    Sir I added the edittemplate in my code and included also the label. But nothings happen, when I search some records and the result were 2 datas still the look of my gridview is like in the post #3.

  16. #16
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Question Again

    Hello,

    Is it possible that you can show all of the ASPX markup that you are using for the page?

    Gary

  17. #17

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Re: Gridview Question Again

    Sir just a quick question, but doing that edittemplate, when I query and the result were nothing, does it produce a 10 blank rows ? Cause my pageindexing number limited to 10.

  18. #18
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Question Again

    Hello,

    I am really not sure what you are asking there.

    I really think it would help if you show the ASPX markup that you are using.

    Gary

  19. #19

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Re: Gridview Question Again

    Well I just resolved it temporarily, I just added a blank row in my datatable to look like this, even its no result or less than 10 result just to fixed the display row.

    But if you have any other solutions then that maybe great, its good to have alternatives .

    This is my MARKUP
    Code:
    <div id="gridview_div" 
                style="position:absolute; top: 178px; left: 532px; height: 395px; width: 817px;">
                <asp:GridView ID="dgvRequirements" runat="server" 
                    style="position:absolute; top: 8px; left: 8px; height: 369px; width: 801px;" 
                    AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" 
                    Font-Names="Arial" Font-Size="8pt" BackColor="White" 
                    BorderColor="#336666" BorderStyle="Double" BorderWidth="3px">
                    <FooterStyle BackColor="White" ForeColor="#333333" />
                    <RowStyle BackColor="White" ForeColor="#333333" />
                    <Columns>
                        <asp:BoundField DataField="NAME" HeaderText="Name" />
                        <asp:BoundField DataField="ADDRESS" HeaderText="Address" />
                        <asp:BoundField DataField="L_NAME" HeaderText="Lastname" />
                        <asp:BoundField DataField="F_NAME" HeaderText="Firstname" />
                        <asp:BoundField DataField="KIND" HeaderText="Kind" />
                        <asp:BoundField DataField="LINE" HeaderText="Line" />
                        <asp:BoundField DataField="CTRL" HeaderText="Control" 
                            Visible="False" />
                        <asp:BoundField DataField="APP_TYPE" HeaderText="Application Type" 
                            Visible="False" />
                    </Columns>
                    <PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
                </asp:GridView>
    Attached Images Attached Images  

  20. #20
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Question Again

    So, I still don't see an EmptyDataTemplate within your ASPX markup.

    Did you try this?

    Gary

  21. #21

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Re: Gridview Question Again

    Yeep, I tried that, when there were no result it will display the label. But what I want to achieve is whether no results or less than data results I still want my gridview to display 10 rows, just like the attached image on my last post. But as I have said I figured it out by adding empty datarow in my datatable. But If you have a simple solution that would be a great help .

  22. #22
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Question Again

    Hey,

    Why do you want to display 10 empty rows?

    That doesn't seem to make any sense?!? What exactly are you trying to achieve?

    Gary

  23. #23

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Re: Gridview Question Again

    Because if theres no result at all. My design would turn out into just plain white and nothing but the buttons, yeah i know that is lame, but I just want to maintain the design that I've done .

  24. #24
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Question Again

    Hey,

    Personally, I don't think that is a valid approach.

    If there are no rows returned from your query, then you should indicate that to the user by putting "something" in the EmptyDataTemplate, not create empty rows simply for the sake of it.

    Gary

  25. #25

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Re: Gridview Question Again

    Actually, after i filled the gridview with that kind of data a messagebox will be shown also, telling the user that no records found.

  26. #26
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Question Again

    Again, personally, I feel that this would be the wrong approach, but that is just my opinion. Why would I want to see a pop up message, that I will have to click on to make go away, when I could be shown this directly in the GridView.

    This is really up to you. How you implement your site is your own opinion.

    Gary

  27. #27

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Re: Gridview Question Again

    Well I guess you got me there . BTW before I resolve my thread, what is really the purpose of EmptyDataTemplate ?

  28. #28
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Gridview Question Again

    Hey,

    It is pretty much exactly as described.

    Within that particular template, you put the "stuff", i.e. a label, or something else, that you want the GridView to display, when there are no results returned from it's datasource.

    Gary

  29. #29

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Re: Gridview Question Again

    just to be cleared . Thanks

  30. #30
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] Gridview Question Again

    Not a problem at all. Hope you get it all working the way you want.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width