This is a migrated thread and some comments may be shown as answers.

set column width individually and horizontal line between two rows

14 Answers 313 Views
Grid
This is a migrated thread and some comments may be shown as answers.
kamini
Top achievements
Rank 1
kamini asked on 14 Aug 2010, 12:26 PM
Hello

i have used <telerik:GridTemplateColumn> for each column in RadGrid... and have some issues like
1). Though i have provided width value to each column, there is no effect shown. when i used TableLayout="Fixed", each column is shown with provided width but rows' height are not looking proper. so is anyone let me know how to set individual column width?
2). i don't want horizontal lines between two rows. how to make it disable?
3). Though i set AllowPaging="True" and PageSize="20" and there are total 50 records as a result, than why its not showing paging?

thank you
Kamini

14 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 16 Aug 2010, 08:38 AM
Hello Kamoni,

1. In order to set column width, set TableLayout as "Fixed" and then set HeaderStyle Width for each column.

2. You can hide the horizontal grid lines by using custom CSS which overrides default skin or create a custom skin that matches your requirement. Please refer the following forum which describes similar kind of scenario.
GridLines in Radgrid

3. Check whether you have set different PageSize in RadGrid and MasterTableView. This may be the reason for not showing paging in grid.

Hope this information helps,
Princy.
0
kamini
Top achievements
Rank 1
answered on 18 Aug 2010, 12:01 PM
thanks Princy for replying..

1st two problems are solved but still there is some problem with paging... when i m trying to move to another page or to change pagesize, grid doesn't appear... what should be the problem..?

thanks
kamini
0
Dimo
Telerik team
answered on 18 Aug 2010, 12:08 PM
Hello Kamini,

Make sure you are data binding the RadGrid control correctly.

http://www.telerik.com/help/aspnet-ajax/grdsimpledatabinding.html

http://www.telerik.com/help/aspnet-ajax/grdadvanceddatabinding.html

http://www.telerik.com/help/aspnet-ajax/grddeclarativedatasource.html

If the problem persists, please send a simple test page.

All the best,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
kamini
Top achievements
Rank 1
answered on 19 Aug 2010, 06:04 AM
Thank you

paging problem is solved but page size changed is still not working.... i have set RadGrid1.PageSize = e.NewPageSize on RadGrid1_PageSizeChanged and its showing an error: An unhandled exception of type 'System.StackOverflowException' occurred in Telerik.Web.UI.DLL...  will you please let me knw what should i do to solve this problem..?

and i have 1 more thing to ask... is it possible to fix header of scrolling grid..?

thanks
Kamini
0
Dimo
Telerik team
answered on 19 Aug 2010, 08:22 AM
Hi Kamini,

You are causing an endless loop - you can't set a new pagesize in the PageSizeChanged event. Why do you want to do that?

You can fix the headers by setting UseStaticHeaders="true" in ClientSettings -> Scrolling.

http://www.telerik.com/help/aspnet-ajax/grdscrollwithstaticheaders.html

http://www.telerik.com/help/aspnet-ajax/height-vs-scrollheight.html

Kind regards,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
kamini
Top achievements
Rank 1
answered on 19 Aug 2010, 09:29 AM
thank you Dimo

yes, i came to know that i am causing an endless loop by using PageSizeChanged event when i debug code. then what is the solution of this problem.. if i remove PageSizeChanged event and changing page size from the dropdown beside paging, grid gets disappear.

thank you
kamini
0
Dimo
Telerik team
answered on 19 Aug 2010, 12:09 PM
Hello Kamini,

It will be easier for us to help you if you provide a sample page showing your current RadGrid configuration.

Greetings,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
kamini
Top achievements
Rank 1
answered on 19 Aug 2010, 12:41 PM
Hello

ya sure. here is my RadGrid configuration.

<telerik:RadGrid ID="RadGrid2" runat="server" DataSourceID="SqlDataSource7" BorderColor="#343434" BorderWidth="2px" Height="400px" skin="Black" AllowSorting="True" AllowPaging="True" PageSize="20" Width="860px"  AutoGenerateColumns="false" onpageindexchanged="RadGrid1_PageIndexChanged">

 

    <ClientSettings  AllowDragToGroup="true" AllowColumnsReorder="true" ReorderColumnsOnClient="true"  ColumnsReorderMethod="Reorder">                      
<Scrolling AllowScroll="True" UseStaticHeaders="true" SaveScrollPosition="true" >    
</Scrolling>                    
</ClientSettings>

     <SortingSettings SortedBackColor="Black" />

     <ItemStyle BackColor="Black" ForeColor="#A7A7A7" />

    <MasterTableView AlternatingItemStyle-BackColor="Black" BackColor="Black" HeaderStyle-HorizontalAlign="Center" TableLayout="Fixed" AlternatingItemStyle-ForeColor="#A7A7A7" GridLines="None" PageSize="20">

      <Columns>

         <telerik:GridTemplateColumn HeaderStyle-Width="50px">

               <ItemTemplate>

                     <input type="checkbox" name="ChkRefNo" value="<%# Eval("CID") %>" />

              </ItemTemplate>

        </telerik:GridTemplateColumn>

        <telerik:GridTemplateColumn HeaderText="Name" HeaderStyle-Width="80px">

             <ItemTemplate>

                     <asp:Label ID="Label2" runat="server" Text='<%# Eval("CustName") %>'></asp:Label>

             </ItemTemplate>

       </telerik:GridTemplateColumn>

        <telerik:GridTemplateColumn HeaderText="BirthDate" HeaderStyle-Width="80px">

            <ItemTemplate>

                     <asp:Label ID="lblbdate" runat="server" Text='<%# Eval("DOBDate") %>'></asp:Label>

            </ItemTemplate>

       </telerik:GridTemplateColumn>

       <telerik:GridTemplateColumn HeaderText="Company Name" HeaderStyle-Width="80px">

             <ItemTemplate>

                      <asp:Label ID="lblCompanyName" runat="server" Text='<%# Eval("CompanyName") %>'></asp:Label>

             </ItemTemplate>

       </telerik:GridTemplateColumn>

       <telerik:GridTemplateColumn HeaderText="Designation" HeaderStyle-Width="80px">

              <ItemTemplate>

                       <asp:Label ID="lblDesignation" runat="server" Text='<%# Eval("Designation") %>'></asp:Label>

              </ItemTemplate>

       </telerik:GridTemplateColumn>

       <telerik:GridTemplateColumn HeaderText="Address" HeaderStyle-Width="80px">

               <ItemTemplate>

                         <asp:Label ID="lblAddress" runat="server" Text='<%# Eval("Address") %>'></asp:Label>

               </ItemTemplate>

       </telerik:GridTemplateColumn>

       <telerik:GridTemplateColumn HeaderText="City" HeaderStyle-Width="80px">

               <ItemTemplate>

                          <asp:Label ID="lblCity" runat="server" Text='<%# Eval("City") %>'></asp:Label>

               </ItemTemplate>

       </telerik:GridTemplateColumn>

       <telerik:GridTemplateColumn HeaderText="State" HeaderStyle-Width="100px">

                <ItemTemplate>

                         <asp:Label ID="lblState" runat="server" Text='<%# Eval("State") %>'></asp:Label>

                </ItemTemplate>

      </telerik:GridTemplateColumn>

       <telerik:GridTemplateColumn HeaderText="Zipcode" HeaderStyle-Width="80px">

                <ItemTemplate>

                         <asp:Label ID="lblZipcode" runat="server" Text='<%# Eval("Zipcode") %>'></asp:Label>

                </ItemTemplate>

       </telerik:GridTemplateColumn>

       <telerik:GridTemplateColumn HeaderText="EmailID" HeaderStyle-Width="80px">

                 <ItemTemplate>

                          <asp:Label ID="lblEmailID" runat="server" Text='<%# Eval("EmailID") %>'></asp:Label>

                 </ItemTemplate>

       </telerik:GridTemplateColumn>

 </Columns>

</MasterTableView>
</telerik:RadGrid>

<asp:SqlDataSource ID="SqlDataSource10" runat="server" SelectCommand="SELECT CustID, CustName, DOBDate, CompanyName, Designation, Address, City, State, Zipcode, EmailID FROM CustomerID"

ConnectionString ="<%$ ConnectionStrings:sanghvi_DataConnectionString %>">

</asp:SqlDataSource>


thank you
kamini
0
Dimo
Telerik team
answered on 19 Aug 2010, 01:50 PM
Hi Kamini,

Your RadGrid declaration and the paging works correctly on my side. Below is my test page using the NorthWind database. By the way, I am surprised that the DataSourceID for RadGrid is SqlDataSource7, while the ID of the SqlDataSource control is SqlDataSource10.

<%@ Page Language="C#" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
<head runat="server">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>RadControls</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
 
 
<telerik:RadGrid ID="RadGrid2" runat="server" DataSourceID="SqlDataSource10" BorderColor="#343434"
    BorderWidth="2px" Height="400px" Skin="Black" AllowSorting="True" AllowPaging="True"
    PageSize="5" Width="860px">
    <ClientSettings AllowDragToGroup="true" AllowColumnsReorder="true" ReorderColumnsOnClient="true"
        ColumnsReorderMethod="Reorder">
        <Scrolling AllowScroll="True" UseStaticHeaders="true" SaveScrollPosition="true">
        </Scrolling>
    </ClientSettings>
    <SortingSettings SortedBackColor="Black" />
    <ItemStyle BackColor="Black" ForeColor="#A7A7A7" />
    <MasterTableView AlternatingItemStyle-BackColor="Black" BackColor="Black" HeaderStyle-HorizontalAlign="Center"
        TableLayout="Fixed" AlternatingItemStyle-ForeColor="#A7A7A7" GridLines="None"
        PageSize="5">
    </MasterTableView>
</telerik:RadGrid>
 
<asp:SqlDataSource ID="SqlDataSource10" runat="server"
    SelectCommand="SELECT * FROM Customers" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" />
 
</form>
</body>
</html>


Kind regards,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
kamini
Top achievements
Rank 1
answered on 20 Aug 2010, 01:23 PM
Hello

ohh i am so sorry.. by mistake i hv paste SqlDataSource10. actually in my code, grid is bind from code behind. n now page size changing is working but the Next and Previous buttons do not work. i have also tried EnableViewState="true". but stril its not working.
i m getting an error: "Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/>"

string strSQL="SELECT CustID, CustName, DOBDate, CompanyName, Designation, Address, City, State, Zipcode, EmailID FROM CustomerID";

SqlDataSource7.SelectCommand = strSQL;

RadGrid1.DataBind();

thank you
kamini

0
Dimo
Telerik team
answered on 20 Aug 2010, 01:27 PM
Hello Kamini,

The test page in my previous post works as expected. Please provide a similar runnable web page, which reproduces the described problem.

Greetings,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
kamini
Top achievements
Rank 1
answered on 21 Aug 2010, 06:26 AM
hello

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GridDemo.aspx.cs" Inherits="SlederExmp.GridDemo" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>Untitled Page</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

        <asp:ScriptManager ID="ScriptManager1" runat="server" />

<telerik:RadGrid ID="RadGrid2" runat="server" DataSourceID="SqlDataSource7" BorderColor="#343434"

BorderWidth="2px" Height="400px" skin="Black" AllowSorting="True" AllowPaging="True" EnableViewState="true"

PageSize="20" Width="860px"  AutoGenerateColumns="false" onpageindexchanged="RadGrid1_PageIndexChanged">

 

    <ClientSettings  AllowDragToGroup="true" AllowColumnsReorder="true" ReorderColumnsOnClient="true" 

    ColumnsReorderMethod="Reorder">                     

    <Scrolling AllowScroll="True" UseStaticHeaders="true" SaveScrollPosition="true" >   

    </Scrolling>                   

    </ClientSettings>

     <SortingSettings SortedBackColor="Black" />

     <ItemStyle BackColor="Black" ForeColor="#A7A7A7" />

    <MasterTableView AlternatingItemStyle-BackColor="Black" BackColor="Black" HeaderStyle-HorizontalAlign="Center"

     TableLayout="Fixed" AlternatingItemStyle-ForeColor="#A7A7A7" GridLines="None" PageSize="20">

        <Columns>

         <telerik:GridTemplateColumn HeaderStyle-Width="50px">

               <ItemTemplate>

                     <input type="checkbox" name="ChkRefNo" value="<%# Eval("CID") %>" />

              </ItemTemplate>

        </telerik:GridTemplateColumn>

        <telerik:GridTemplateColumn HeaderText="Name" HeaderStyle-Width="80px">

             <ItemTemplate>

                     <asp:Label ID="Label2" runat="server" Text='<%# Eval("CustName") %>'></asp:Label>

             </ItemTemplate>

       </telerik:GridTemplateColumn>

        <telerik:GridTemplateColumn HeaderText="BirthDate" HeaderStyle-Width="80px">

            <ItemTemplate>

                     <asp:Label ID="lblbdate" runat="server" Text='<%# Eval("DOBDate") %>'></asp:Label>

            </ItemTemplate>

       </telerik:GridTemplateColumn>

       <telerik:GridTemplateColumn HeaderText="Company Name" HeaderStyle-Width="80px">

             <ItemTemplate>

                      <asp:Label ID="lblCompanyName" runat="server" Text='<%# Eval("CompanyName") %>'></asp:Label>

             </ItemTemplate>

       </telerik:GridTemplateColumn>

       <telerik:GridTemplateColumn HeaderText="Designation" HeaderStyle-Width="80px">

              <ItemTemplate>

                       <asp:Label ID="lblDesignation" runat="server" Text='<%# Eval("Designation") %>'></asp:Label>

              </ItemTemplate>

       </telerik:GridTemplateColumn>

       <telerik:GridTemplateColumn HeaderText="Address" HeaderStyle-Width="80px">

               <ItemTemplate>

                         <asp:Label ID="lblAddress" runat="server" Text='<%# Eval("Address") %>'></asp:Label>

               </ItemTemplate>

       </telerik:GridTemplateColumn>

       <telerik:GridTemplateColumn HeaderText="City" HeaderStyle-Width="80px">

               <ItemTemplate>

                          <asp:Label ID="lblCity" runat="server" Text='<%# Eval("City") %>'></asp:Label>

               </ItemTemplate>

       </telerik:GridTemplateColumn>

       <telerik:GridTemplateColumn HeaderText="State" HeaderStyle-Width="100px">

                <ItemTemplate>

                         <asp:Label ID="lblState" runat="server" Text='<%# Eval("State") %>'></asp:Label>

                </ItemTemplate>

      </telerik:GridTemplateColumn>

       <telerik:GridTemplateColumn HeaderText="Zipcode" HeaderStyle-Width="80px">

                <ItemTemplate>

                         <asp:Label ID="lblZipcode" runat="server" Text='<%# Eval("Zipcode") %>'></asp:Label>

                </ItemTemplate>

       </telerik:GridTemplateColumn>

       <telerik:GridTemplateColumn HeaderText="EmailID" HeaderStyle-Width="80px">

                 <ItemTemplate>

                          <asp:Label ID="lblEmailID" runat="server" Text='<%# Eval("EmailID") %>'></asp:Label>

                 </ItemTemplate>

       </telerik:GridTemplateColumn>

 </Columns>

</MasterTableView>

</telerik:RadGrid>

<asp:SqlDataSource ID="SqlDataSource7" runat="server"

    ConnectionString="<%$ ConnectionStrings:DataConnectionString %>"></asp:SqlDataSource>

    </div>

    </form>

</body>

</html>


 

using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

 

namespace SlederExmp

{

    public partial class GridDemo : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            if (Session["CID"] == null)

            {

                Response.Redirect("Home.aspx");

            }

            BindGrid();

        }

 

        public void BindGrid()

        {

            string strSQL = "SELECT CustID, CustName, DOBDate, CompanyName, Designation, Address, City, State, Zipcode, EmailID FROM CustomerID";

            if (Session["Cstatus"] != null)

            {

                strSQL = strSQL + " where CustStatus='Y'";

            }

            strSQL = strSQL + " order by CustName";

            SqlDataSource7.SelectCommand = strSQL;

            RadGrid1.DataBind();

        }

 

        protected void RadGrid1_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e)

        {

            RadGrid1.CurrentPageIndex = e.NewPageIndex;

            BindGrid();

        }

    }

}

n if i wrap BindGrid() in !IsPostBack, thn page size changing does not work bcoz BindGrid() can't be called.

thank you
kamini

 

0
Dimo
Telerik team
answered on 23 Aug 2010, 02:04 PM
Hello Kamini,

Why are you using declarative datasource (DataSourceID="..") and simple data binding in Page_Load at the same time? You should use only one of these techniques - in your case, preferrably declarative datasource, because paging is not supported automatically with simple databinding.

Please make sure you read and understand all the information provided in the following help articles:

http://www.telerik.com/help/aspnet-ajax/grdsimpledatabinding.html

http://www.telerik.com/help/aspnet-ajax/grdadvanceddatabinding.html

http://www.telerik.com/help/aspnet-ajax/grddeclarativedatasource.html

Also, remove the PageIndexChanged event handler, as it causes an infinite loop.

I recommend you to inspect our paging-related online demos as well.

http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/paging/defaultcs.aspx


Best wishes,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
kamini
Top achievements
Rank 1
answered on 26 Aug 2010, 06:46 AM
thank you Dimo

my problem is solved.  now i come to know where i was stuck. i was binding Grid on BindGrid() function that was wrong. Because on NeedDataSource event, RadGrid can automatically be bind.

thank you again.

Regards
Kamini
Tags
Grid
Asked by
kamini
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
kamini
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or