in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Problem with C1WebGrid Height

Last post 02-20-2008 10:58 AM by mferia23sd. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 02-15-2008 2:43 AM

    Problem with C1WebGrid Height

    Hi All,

     I using C1 WebGrid 2.0 version. I need to showing data on different tabs and in each tab I want to show C1 WebGrid. Firstly I tried to do something like this:

    <C1WebGrid:C1WebGrid ID="C1WebGrid1" runat="server" AutoGenerateColumns="False" BackColor="White" GridLines="Both"  ScrollBarStyle="Always" VScrollBarStyle="Always"

    CssClass="grid-text">

    <headerstyle horizontalalign="Left" wrap="true" font-bold="True" cssclass="GridHeader"></headerstyle>

    <itemstyle horizontalalign="left" height="35px" wrap="true" verticalalign="Top" borderstyle="None" cssclass="GridRowColor" />

    <alternatingitemstyle cssclass="GridAlternateRowColor" bordercolor="Black"></alternatingitemstyle>

    </C1WebGrid:C1WebGrid>

    and in code behind C1WebGrid1.DataSource = ds.Tables["tb_1"];

    C1WebGrid1.DataBind();

    But here is doesnt take the columns so I add all the column in the code behind and even the C1WebGrid. below is the Code:

    C1WebGrid C1WebGrid1= new C1WebGrid();

    C1WebGrid1.AutoGenerateColumns = false;

    foreach (DataColumn objDC in ds.Tables["tb_11"].Columns)

    {

    C1BoundColumn ID = new C1BoundColumn();

    ID.DataField = objDC.ColumnName;

    ID.HeaderText = objDC.ColumnName;

    if (objDC.ColumnName == "Description")

    {

    ID.AllowAutoSize =
    true;ID.ItemStyle.Wrap = true;

    }

    else

    {

    ID.DataFormatString =
    "{0:n2}";

    }

    C1WebGrid1.Columns.Add(ID);

    }

    C1WebGrid1.Height = new Unit(350);

    C1WebGrid1.DataSource = ds.Tables["tb_11"];

    C1WebGrid1.DataBind();

    C1WebGrid1.ItemStyle.CssClass = "GridRowColor";

    C1WebGrid1.AlternatingItemStyle.CssClass = "GridAlternateRowColor"; C1WebGrid1.HeaderStyle.CssClass = "GridHeader";

    C1WebGrid1.Columns[2].Fixed = true;

    C1WebGrid1.Columns[2].ItemStyle.Width = new Unit(250);

     

    C1WebGrid1.HScrollBarStyle = C1ScrollBarStyle.Always;

    C1WebGrid1.VScrollBarStyle = C1ScrollBarStyle.Always; C1WebGrid1.Columns[0].Visible = false;

    C1WebGrid1.Columns[1].Visible = false;

    C1WebGrid1.Columns[3].Visible = false;

    td.Controls.Add(C1WebGrid1);

    But I cant Fix the height.

    Please help me with this...

    Thanks in advance...

    Filed under:
  • 02-15-2008 4:23 AM In reply to

    Re: Problem with C1WebGrid Height

    Please try to assign the VScrollbarStyle and HScrollbarStyle before you assign datasource to the control and then databind.
     

    C1WebGrid C1WebGrid1 = new C1WebGrid();

    this.PlaceHolder1.Controls.Add(C1WebGrid1);

    C1WebGrid1.AutoGenerateColumns = false;

    DataView dv = (DataView)this.SqlDataSource1.Select(new DataSourceSelectArguments());

    foreach (DataColumn objDC in dv.Table.Columns)

    {

    C1BoundColumn ID = new C1BoundColumn();

    ID.DataField = objDC.ColumnName;

    ID.HeaderText = objDC.ColumnName;

    C1WebGrid1.Columns.Add(ID);

    }

    C1WebGrid1.Height = new Unit(350);

    C1WebGrid1.Width = new Unit(250);

    C1WebGrid1.Columns[2].Fixed = true;

    C1WebGrid1.HScrollBarStyle = C1ScrollBarStyle.Always;

    C1WebGrid1.VScrollBarStyle = C1ScrollBarStyle.Always;

    C1WebGrid1.DataSource = dv;

    C1WebGrid1.DataBind();

    Regards,

    Patrick

    <varshavmane> wrote in message news:201973@10.0.1.98...

    Hi All,

     I using C1 WebGrid 2.0 version. I need to showing data on different tabs and in each tab I want to show C1 WebGrid. Firstly I tried to do something like this:

    <C1WebGrid:C1WebGrid ID="C1WebGrid1" runat="server" AutoGenerateColumns="False" BackColor="White" GridLines="Both"  ScrollBarStyle="Always" VScrollBarStyle="Always"

    CssClass="grid-text">

    <headerstyle horizontalalign="Left" wrap="true" font-bold="True" cssclass="GridHeader"></headerstyle>

    <itemstyle horizontalalign="left" height="35px" wrap="true" verticalalign="Top" borderstyle="None" cssclass="GridRowColor" />

    <alternatingitemstyle cssclass="GridAlternateRowColor" bordercolor="Black"></alternatingitemstyle>

    </C1WebGrid:C1WebGrid>

    and in code behind C1WebGrid1.DataSource = ds.Tables["tb_1"];

    C1WebGrid1.DataBind();

    But here is doesnt take the columns so I add all the column in the code behind and even the C1WebGrid. below is the Code:

    C1WebGrid C1WebGrid1= new C1WebGrid();

    C1WebGrid1.AutoGenerateColumns = false;

    foreach (DataColumn objDC in ds.Tables["tb_11"].Columns)

    {

    C1BoundColumn ID = new C1BoundColumn();

    ID.DataField = objDC.ColumnName;

    ID.HeaderText = objDC.ColumnName;

    if (objDC.ColumnName == "Description")

    {

    ID.AllowAutoSize =
    true;ID.ItemStyle.Wrap = true;

    }

    else

    {

    ID.DataFormatString =
    "{0:n2}";

    }

    C1WebGrid1.Columns.Add(ID);

    }

    C1WebGrid1.Height = new Unit(350);

    C1WebGrid1.DataSource = ds.Tables["tb_11"];

    C1WebGrid1.DataBind();

    C1WebGrid1.ItemStyle.CssClass = "GridRowColor";

    C1WebGrid1.AlternatingItemStyle.CssClass = "GridAlternateRowColor"; C1WebGrid1.HeaderStyle.CssClass = "GridHeader";

    C1WebGrid1.Columns[2].Fixed = true;

    C1WebGrid1.Columns[2].ItemStyle.Width = new Unit(250);

     

    C1WebGrid1.HScrollBarStyle = C1ScrollBarStyle.Always;

    C1WebGrid1.VScrollBarStyle = C1ScrollBarStyle.Always; C1WebGrid1.Columns[0].Visible = false;

    C1WebGrid1.Columns[1].Visible = false;

    C1WebGrid1.Columns[3].Visible = false;

    td.Controls.Add(C1WebGrid1);

    But I cant Fix the height.

    Please help me with this...

    Thanks in advance...



    http://helpcentral.componentone.com/cs/forums/p/74332/201973.aspx#201973

  • 02-15-2008 5:02 AM In reply to

    Re: Problem with C1WebGrid Height

    Thanks for the reply sir. I did what u told but its giving problem for hortizontal scroll. Here is the code:

    DataView dv = (DataView)dsTables["tb_11"].DefaultView;

    foreach (DataColumn objDC in dv.Table.Columns)

    {

    C1BoundColumn ID = new C1BoundColumn();

    ID.DataField = objDC.ColumnName;

    ID.HeaderText = objDC.ColumnName;

     

    C1WebGrid1.Columns.Add(ID);

    }

    C1WebGrid1.Height =
    new Unit(350);

    C1WebGrid1.Width = new Unit(250);

    C1WebGrid1.Columns[2].Fixed = true;

    C1WebGrid1.HScrollBarStyle = C1ScrollBarStyle.Always;

    C1WebGrid1.VScrollBarStyle = C1ScrollBarStyle.Always;

    C1WebGrid1.DataSource = dv;

    C1WebGrid1.DataBind();

    Please tell me where I am doing mistake...

     Thanks again...

    Filed under:
  • 02-20-2008 3:47 AM In reply to

    Re: Problem with C1WebGrid Height

    Hi,
     
    first, you'll need to explicitly specify grid height and width to make scrolling working. Second, make data binding the last line of code related to the grid. Also, try the latest version of the grid available at http://prerelease.componentone.com/
     
    Regards,
    Sergey.
    <varshavmane> wrote in message news:201978@10.0.1.98...

    Thanks for the reply sir. I did what u told but its giving problem for hortizontal scroll. Here is the code:

    DataView dv = (DataView)dsTables["tb_11"].DefaultView;

    foreach (DataColumn objDC in dv.Table.Columns)

    {

    C1BoundColumn ID = new C1BoundColumn();

    ID.DataField = objDC.ColumnName;

    ID.HeaderText = objDC.ColumnName;

     

    C1WebGrid1.Columns.Add(ID);

    }

    C1WebGrid1.Height =
    new Unit(350);

    C1WebGrid1.Width = new Unit(250);

    C1WebGrid1.Columns[2].Fixed = true;

    C1WebGrid1.HScrollBarStyle = C1ScrollBarStyle.Always;

    C1WebGrid1.VScrollBarStyle = C1ScrollBarStyle.Always;

    C1WebGrid1.DataSource = dv;

    C1WebGrid1.DataBind();

    Please tell me where I am doing mistake...

     Thanks again...



    http://helpcentral.componentone.com/cs/forums/p/74332/201978.aspx#201978

  • 02-20-2008 10:58 AM In reply to

    Re: Problem with C1WebGrid Height

    The functionality that I need is move between the rows of the grid with the keys up and down, with the possibility of highlighting the selected row.
    It is the same thing that the Button SELECT, but with the keys of direction.

    Thanks again...

     

Page 1 of 1 (5 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.