Hi, Im having problem with my gridBoundColumn. It duplicates whenever there some server command thats been executed. The only column thats not duplicating is my gridTemplateColumn. Im populating my columns purely in code behind. Radgrid was defined on aspx with several properties but without any column. The funny thing about it is that I use to count my columns before it adds columns to the grid. Before adding any columns value is 0 and after adding all the columns value is just 8. But if Im gonna count all of the columns (1 template column which theres no duplication) and there are 5 sets of same 7 columns if I it executes some server codes or post back 5x.. Its like at first load it shows correct 8 columns, and when I do change my dropdown it will have some postback and then my grid count becomes (1 templatecolumn) and 2 sets of 7 so total columns is 15. and when I do change again my dropdown it will have (1 template column) and 3 sets of 7 columns Its like this:
Chkbox Tempcol|Fname|Lname|TelNo|Add|City|State|Zip|Fname|Lname|TelNo|Add|City|State|Zip|Fname|Lname|TelNo|Add|City|State|Zip
Heres my code
Code behind
Any feedback would be appreciated.
Thanks in advance,
RJ
Chkbox Tempcol|Fname|Lname|TelNo|Add|City|State|Zip|Fname|Lname|TelNo|Add|City|State|Zip|Fname|Lname|TelNo|Add|City|State|Zip
Heres my code
<rad:radgrid id="RadGrid1" runat="server" Height="200px" AllowMultiRowSelection="True" ForeColor="White" AllowMultiRowEdit="True" Skin="outlook" width="985px" ItemStyle-BackColor="WhiteSmoke" AlternatingItemStyle-BackColor="White" BorderStyle="None" GridLines="Both"> |
<AlternatingItemStyle Font-Size="Small" Font-Names="Arial Narrow" HorizontalAlign="Left" VerticalAlign="Middle" BorderStyle="None" CssClass="AlternatingItemRow" BackColor="White"></AlternatingItemStyle> |
<MasterTableView DataKeyNames="ID" AllowAutomaticInserts="True" EditMode="InPlace" CommandItemDisplay="Top" AutoGenerateColumns="False"> |
<CommandItemStyle BackColor="#FFE39A"></CommandItemStyle> |
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle"></ItemStyle> |
<CommandItemTemplate> |
<table class="MyCommandItemClass" width="100%"> |
<tr> |
<td align="left" style="width: 75%; padding-top:4px"> |
<asp:Label ID="lblPN" runat="server" Text="PlanName" CssClass="basicfontbold" ForeColor="black" Font-Size="12px" Visible="true"></asp:Label> |
</td> |
<td align="right"> |
<asp:Button id="btnAdd" Runat="server" CommandName="InitInsert" ToolTip="Add New Record" Text="Add" CssClass="ButtonGray" Visible='<%# Not RadGrid1.MasterTableView.IsItemInserted and showInsert %>' /> |
<asp:Button ID="PerformInsert" runat="server" CommandName="PerformInsert" ToolTip="Save" CssClass="ButtonRed" Text="Save" Visible='<%# RadGrid1.MasterTableView.IsItemInserted and showInsert %>'/> |
<asp:Button ID="CancelInsert" runat="server" CommandName="CancelInsert" ToolTip="Cancel" CssClass="ButtonGray" Text="Cancel" Visible='<%# RadGrid1.MasterTableView.IsItemInserted and showInsert %>'/> |
<asp:Button id="Linkbutton1" Runat="server" CommandName="DeleteChecked" Text="Delete" CssClass="ButtonGray" Visible='<%# Not RadGrid1.MasterTableView.IsItemInserted and showDelete %>' Enabled='<%# showDelete %>'/> |
</td> |
</tr> |
</table> |
</CommandItemTemplate> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</ExpandCollapseColumn> |
<FooterStyle BorderStyle="None" BackColor="#FFE39A"></FooterStyle> |
</MasterTableView> |
<HeaderStyle Font-Size="Small" Font-Names="Arial Narrow" Font-Bold="True" ForeColor="White" ></HeaderStyle> |
<SelectedItemStyle CssClass="RadGridSelectedItem"></SelectedItemStyle> |
<ItemStyle Font-Size="Small" Font-Names="Arial Narrow" HorizontalAlign="Left" VerticalAlign="Middle"></ItemStyle> |
<ClientSettings> |
<Selecting AllowRowSelect="True" EnableDragToSelectRows="False"></Selecting> |
<Resizing ResizeGridOnColumnResize="True" AllowColumnResize="True"></Resizing> |
<ClientEvents OnRowDeselected="RowDeselected" OnRowSelected="RowSelected" OnRowCreated="RowCreated"></ClientEvents> |
<Scrolling ScrollHeight="202px" AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" FrozenColumnsCount="5"></Scrolling> |
</ClientSettings> |
</rad:radgrid> |
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init |
Dim boundColumn As GridBoundColumn |
Dim colcount as int16 = RadGrid1.MasterTableView.Columns.Count |
Try |
boundColumn = New GridBoundColumn() |
RadGrid1.MasterTableView.Columns.Add(boundColumn) |
boundColumn.HeaderText = "ID" |
boundColumn.DataField = "ID" |
boundColumn.UniqueName = "ID" |
boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left |
boundColumn.ItemStyle.VerticalAlign = VerticalAlign.Middle |
boundColumn.ReadOnly = True |
boundColumn.Visible = False |
Catch ex As Exception |
End Try |
Try |
Dim templateColumnName As String = "Delete" |
Dim templateColumn As New GridTemplateColumn() |
templateColumn.ItemTemplate = New GridCheckboxTemplate(templateColumnName) |
templateColumn.HeaderImageUrl = "images/delete.gif" |
templateColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Center |
templateColumn.HeaderStyle.HorizontalAlign = HorizontalAlign.Left |
templateColumn.ItemStyle.VerticalAlign = VerticalAlign.Middle |
templateColumn.HeaderStyle.Width = Unit.Pixel(23) |
templateColumn.ItemStyle.Width = Unit.Pixel(35) |
RadGrid1.MasterTableView.Columns.Add(templateColumn) |
Catch ex As Exception |
End Try |
Try |
boundColumn = New GridBoundColumn() |
boundColumn.HeaderText = "Fname" |
boundColumn.DataField = "Fname" |
boundColumn.UniqueName = "Fname" |
boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left |
boundColumn.ItemStyle.VerticalAlign = VerticalAlign.Middle |
boundColumn.HeaderStyle.Width = Unit.Pixel(100) |
boundColumn.ItemStyle.Width = Unit.Pixel(100) |
RadGrid1.MasterTableView.Columns.Add(boundColumn) |
Catch ex As Exception |
End Try |
Several more columns defined here..... |
colcount = RadGrid1.MasterTableView.Columns.Count |
RadGrid1 Code Binding here....... end Sub |
Any feedback would be appreciated.
Thanks in advance,
RJ