Hi,
We have found the following behavior with Web Grid, and want to confirm if the same is a bug.
Created an Unbound column of CheckBox Type, and placed a 'Test Postback' on the page (outside the WebGrid).
Check one or more Check Boxes
Click 'Test Postback'
It works fine for the first postback.
User sees Check Boxes selected still.
Click 'Test Postback' again
This empties unchecks all Check Boxes in the Column.
Can somebody tell me if this behavior is by design or is a bug?
Also, is there any solution as we need to keep the CheckBox selection as is across all postbacks (Except converting the unbound column to a bound column and preserving its state in source data object).
Regards,
MPVBRao.
Did you add the unbound column in code or in the designer?
If you added the column in code, how did you do it? It's possible that the column isn't being stored in ViewState. Depending on how you created the column object, this might be an expected result. The following post provides more details on this behavior, and how to get around it:https://www.infragistics.com/community/forums/f/ultimate-ui-for-windows-forms/52172/ultracombo-with-dropdownlist-style-has-missing-borders#52172
It is defined in design as given below,
<igtbl:UltraGridColumn Key="Select" Type="CheckBox" DataType="System.Boolean" Width="1%"
AllowUpdate="Yes">
<Header Caption="Select">
<RowLayoutColumnInfo OriginX="7" />
</Header>
<Footer>
</Footer>
</igtbl:UltraGridColumn>
Thanks & Regards,
That's odd.
Are you re-binding your grid during a postback, such as in the Page_Load event?
No, there is no databind statement, as I am handling InitializeDataSource event
Thanks for the quick response.
Here is the complete code that reproduces the behavior.
Default.ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
<%@ Register Assembly="Infragistics35.WebUI.UltraWebGrid.v8.3, Version=8.3.20083.2021, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"
Namespace="Infragistics.WebUI.UltraWebGrid" TagPrefix="igtbl" @%>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<igtbl:UltraWebGrid ID="samplesListView" runat="server" Height="90%" Width="100%">
<DisplayLayout AutoGenerateColumns="false" ViewType="Flat" AllowColSizingDefault="Free"
AllowColumnMovingDefault="OnServer" AllowDeleteDefault="Yes" AllowSortingDefault="Yes"
AllowUpdateDefault="Yes" BorderCollapseDefault="Separate" HeaderClickActionDefault="SortMulti"
Name="UltraWebGrid1" RowHeightDefault="20px" RowSelectorsDefault="No" SelectTypeRowDefault="Extended"
StationaryMargins="No" StationaryMarginsOutlookGroupBy="True" TableLayout="Fixed"
Version="4.00">
<FrameStyle BackColor="Window" BorderColor="InactiveCaption" BorderStyle="Solid"
BorderWidth="1px" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Height="90%"
Width="100%">
</FrameStyle>
<Pager MinimumPagesForDisplay="1" PageSize="4" AllowPaging="true" PagerAppearance="Both"
StyleMode="QuickPages" QuickPages="5">
<PagerStyle BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px">
<BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" />
</PagerStyle>
</Pager>
<EditCellStyleDefault BorderStyle="None" BorderWidth="0px">
</EditCellStyleDefault>
<FooterStyleDefault BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px">
</FooterStyleDefault>
<HeaderStyleDefault BackColor="LightGray" BorderStyle="Solid" HorizontalAlign="Left">
</HeaderStyleDefault>
<RowStyleDefault BackColor="Window" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Microsoft Sans Serif" Font-Size="8.25pt">
<Padding Left="3px" />
<BorderDetails ColorLeft="Window" ColorTop="Window" />
</RowStyleDefault>
<GroupByRowStyleDefault BackColor="Control" BorderColor="Window">
</GroupByRowStyleDefault>
<GroupByBox>
<BoxStyle BackColor="ActiveBorder" BorderColor="Window">
</BoxStyle>
</GroupByBox>
<AddNewBox Hidden="False">
<BoxStyle BackColor="Window" BorderColor="InactiveCaption" BorderStyle="Solid" BorderWidth="1px">
</AddNewBox>
<ActivationObject BorderColor="" BorderWidth="">
</ActivationObject>
<FilterOptionsDefault FilterUIType="FilterRow" AllowRowFiltering="OnServer" RowFilterMode="AllRowsInBand">
<FilterDropDownStyle BackColor="White" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px"
CustomRules="overflow:auto;" Font-Names="Verdana,Arial,Helvetica,sans-serif"
Font-Size="11px" Height="300px" Width="200px">
<Padding Left="2px" />
</FilterDropDownStyle>
<FilterHighlightRowStyle BackColor="#151C55" ForeColor="White">
</FilterHighlightRowStyle>
<FilterOperandDropDownStyle BackColor="White" BorderColor="Silver" BorderStyle="Solid"
BorderWidth="1px" CustomRules="overflow:auto;" Font-Names="Verdana,Arial,Helvetica,sans-serif"
Font-Size="11px">
</FilterOperandDropDownStyle>
</FilterOptionsDefault>
</DisplayLayout>
<Bands>
<igtbl:UltraGridBand DataKeyField="CompleteSampleNo">
<Columns>
<igtbl:TemplatedColumn Width="1%">
<Header Caption="Action">
<CellTemplate>
<asp:LinkButton ID="testLinkButton1" runat="server" Text="Test DataKey" CommandName="test1"
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "CompleteSampleNo") %>' />
|
<asp:LinkButton ID="testLinkButton2" runat="server" Text="Test CommandArgument" CommandName="test2"
</CellTemplate>
</igtbl:TemplatedColumn>
<igtbl:UltraGridColumn Key="CompleteSampleNo" BaseColumnName="CompleteSampleNo" Width="1%">
<Header Caption="Sample No.">
<RowLayoutColumnInfo OriginX="1"></RowLayoutColumnInfo>
</Columns>
<AddNewRow View="NotSet" Visible="NotSet">
</AddNewRow>
</igtbl:UltraGridBand>
</Bands>
</igtbl:UltraWebGrid>
<asp:Button ID="testPostback" runat="server" Text="Test Postback" />
</div>
</form>
</body>
</html>
Default.ASPX.CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Infragistics.WebUI.UltraWebGrid;
using System.Configuration;
using System.Data;
using System.IO;
public partial class Default : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
this.samplesListView.InitializeDataSource += new InitializeDataSourceEventHandler(samplesListView_InitializeDataSource);
}
public class Sample
public int Batch { get; set; }
public int SampleNumber { get; set; }
public string CompleteSampleNo
get
return string.Format("{0}-{1}", this.Batch, this.SampleNumber);
private void AddSamples(List<Sample> samplesList, int batch, int numberOfSamples)
for (int i = 1; i <= numberOfSamples; i++)
samplesList.Add(new Sample() { Batch = batch, SampleNumber = i });
void samplesListView_InitializeDataSource(object sender, UltraGridEventArgs e)
//prepare some dummy data for the grid
var batchesList = new List<Sample>();
AddSamples(batchesList, 112333, 4);
AddSamples(batchesList, 112334, 3);
AddSamples(batchesList, 112335, 1);
AddSamples(batchesList, 112336, 4);
samplesListView.DataSource = batchesList;
Since you're using the InitializeDataSource event, the grid is implicitly calling DataBind() on every postback. Since you're not persisting the value in these checkboxes in any way, they're lost on the postback that occurs after the postback where they were changed.
I see two options. One is to persist the value of the checkbox on each row in some fashion. The other is to not use the InitializeDataSource event, and thus take direct control as to when you call the grid's DataBind() event.
Ok, I will try to persist the state.
Also could you please explain the below.
Why is the grid showing wrong checkbox state after first postback?, as the same state is not accessible though code in the next postback.
mpvbrao said:Also could you please explain the below. Why is the grid showing wrong checkbox state after first postback?, as the same state is not accessible though code in the next postback
Why is the grid showing wrong checkbox state after first postback?, as the same state is not accessible though code in the next postback
By persisting the state of the checkboxes, restoring them in either InitializeDataSource or InitializeLayout, you'll ensure that the checkboxes remain checked even after subsequent postbacks.
If you instead chose to not use InitializeDataSource, and so long as ViewState is enabled for the grid, the state of the checkboxes would be retrieved from ViewState. So long as you don't DataBind the grid again, the states will persist across multiple postbacks.
Vince McDonald"]There's no event processed this time, since the user didn't change any of the states of the checkboxes.
But how does it know that there are no changes at this time, as the previous stateof checkboxes is not maintained anywhere.
Whatever the case, user should see the same which the developer could access in the postback, but in this case end user is shown false state than what is actually available to the developer, am I right?.
Hello,
I just want to refer to a similar thread I've seen recently and that can provide some help/clues:
http://forums.infragistics.com/forums/p/13065/48331.aspx
I was also able to reproduce that behaviour, but at this point I am not sure if it is by design or a bug - e.g. if the developer should be responsible for keeping the state of unbound checkbox columns. You may want to check out if the client-side approach works better for you. Alternatively you can move to unbound mode or manually take care of the state of the column (e.g. put a list of boolean values in the Session / ViewState / Cache of the application and the restore after postback).
Or, you can contact our Developer Support directly via this link - this way the question will most probably be referred to development for a more complete answer.
http://www.infragistics.com/Support/default.aspx
Sorry for the inconvenience.