Hi,
I am dynamically creating columns(GridBoundColumn and GridNumericColumn). There are nearly 15-16 columns. So have added scroll bars to the Grid to avoid Page scroll bar. I got the Scroll bar for the grid but at the same time I am getting extra space after the Grid which results horizontal scroll bar to the page. Because of this entire layout has been changed.
My ASPX Code:
My Code Behind :
Help me to resolve this issue.
Thanks,
Malli
I am dynamically creating columns(GridBoundColumn and GridNumericColumn). There are nearly 15-16 columns. So have added scroll bars to the Grid to avoid Page scroll bar. I got the Scroll bar for the grid but at the same time I am getting extra space after the Grid which results horizontal scroll bar to the page. Because of this entire layout has been changed.
My ASPX Code:
| <telerik:RadGrid ID="RadGrid1" runat="server" Width="650px" BorderColor="#698AC0" |
| BorderWidth="2px" BorderStyle="Solid" Skin="Vista" GridLines="Both" HeaderStyle-Font-Names="Verdana" |
| HeaderStyle-Font-Size="9px" HeaderStyle-HorizontalAlign="Center" ItemStyle-Font-Size="9px" |
| AutoGenerateColumns="false" AlternatingItemStyle-Font-Names="Verdana" AllowFilteringByColumn="True" |
| CommandItemStyle-Width="50px" |
| OnPreRender="RadGrid1_PreRender" OnNeedDataSource="RadGrid1_NeedDataSource" |
| AllowSorting= "true" AlternatingItemStyle-Font-Size="9px" ShowFooter="true"> |
| <ItemStyle Font-Names="Verdana" Font-Size="9px"></ItemStyle> |
| <FilterItemStyle Font-Names="Verdana" Font-Size="9px" /> |
| <MasterTableView TableLayout="Auto" Width="650px"/> |
| <ClientSettings> |
| <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true"/> |
| </ClientSettings> |
| </telerik:RadGrid> |
My Code Behind :
| protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
| { |
| DataSet RebateData = GetMSRebateDS(); |
| if (RadGrid1.Columns.Count == 0) |
| { |
| if (RebateData.Tables.Count > 0) |
| { |
| foreach (DataColumn Column in RebateData.Tables[0].Columns) |
| { |
| ColList.Add(Column.ColumnName); |
| } |
| } |
| PrepareGridColumns(ColList); |
| } |
| RadGrid1.DataSource = RebateData; |
| } |
| private void PrepareGridColumns(List<string> ColList) |
| { |
| foreach (string Column in ColList) |
| { |
| if (Column == "PartnerName") |
| { |
| GridBoundColumn BoundCol = new GridBoundColumn(); |
| RadGrid1.MasterTableView.Columns.Add(BoundCol); |
| BoundCol.UniqueName = Column; |
| BoundCol.HeaderText = Column; |
| BoundCol.DataField = Column; |
| BoundCol.HeaderStyle.Width = Unit.Pixel(70); |
| BoundCol.FilterControlWidth = Unit.Pixel(40); |
| BoundCol.SortExpression = Column; |
| BoundCol.AllowFiltering = true; |
| } |
| else |
| { |
| GridNumericColumn BoundNumCol = new GridNumericColumn(); |
| RadGrid1.MasterTableView.Columns.Add(BoundNumCol); |
| BoundNumCol.UniqueName = Column; |
| BoundNumCol.HeaderText = Column; |
| BoundNumCol.DataField = Column; |
| BoundNumCol.HeaderStyle.Width = Unit.Pixel(70); |
| BoundNumCol.FilterControlWidth = Unit.Pixel(40); |
| BoundNumCol.SortExpression = Column; |
| BoundNumCol.AllowFiltering = true; |
| } |
| } |
| } |
Help me to resolve this issue.
Thanks,
Malli