I am currently using 11.1.20111.2020 and am experiencing an issue with using an unbound checkbox column in a WebDataGrid. When the user checks a box in a row in this column and posts back twice or more, the value is lost on the second post back. Infragistics currently has a sample in the samples section which works correctly. In my situation, the grid is bound based upon selection criteria and via a button click. It is not bound to a datasource object. The ultrawebgrid does not have this issue.
How do I persist the checked value across subsequent postbacks?
Thanks,
Hi Dev__01,
This sounds like a scenario that should work. You do have on ViewState, right? The unbound values are saved there. You have on EditingCore? This makes the checkboxes editable. Do you have on DataViewState or any other behaviors? If you were to attach some small sample here, I could check it out.
regards,David Young
Hi David - Thanks for responding. Yes the enableviewstate and enabledataviewstate properties are set to true and the editing core is enabled. I'll attach a sample momentarily.
Hi David -
Here is the markup and code behind.
<!—Begin markup -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ig:WebScriptManager ID="wsm1" runat="server" />
<div>
<style type="text/css">
.gridHeader
{
background-color:#4682B4;
color:#FFFFFF;
background-repeat: repeat-x;
background-position: 0 50%;
height: 18px;
border-bottom:solid 1px #D8D8D8;
border-top:solid 1px #D8D8D8;
border-left:solid 1px #D8D8D8;
border-right:solid 1px #D8D8D8;
padding:3px 2px 3px 2px;
border-color:#FFFFFF;
text-align: center;
font-family:"Arial";
font-size:10pt;
}
tbody.igg_ItemIE6 tr td
background-color:White;
border-bottom-color:#D3D3D3;
border-top-color:#D3D3D3;
border-left-color:#D3D3D3;
border-right-color:#D3D3D3;
border-bottom-width:thin;
border-top-width:thin;
border-left-width:thin;
border-right-width:thin;
border-top:solid 2px #D8D8D8;
overflow: hidden;
vertical-align:top;
tbody.igg_Item>tr>td
tbody tr.igg_AltIE6 td
background-color:#FFFFFF;
tbody>tr.igg_Alt>td
.igg_RowSelector
width: 18px;
color:Black;
text-align:center;
vertical-align:middle;
.igg_HeaderRowSelector
.igg_HeaderCaption
font-size: 12px;
font-weight:normal;
padding-left:0px;
.igg_ActiveRowSelector
background-position:left center ;
background-image: url(ig_res/Default/images/arrow_steel_blue.png);
background-repeat: no-repeat;
/*background-color: #8DC6EC;*/
.igg_SelectedRowSelector
background-color: White;
color: #FFFFFF;
.Field_CSS
padding-top:2px;
border-style:solid;
border-width:thin;
height:14px;
width:150px;
.DayTexBox
border-bottom-style:solid;
border-top-style:solid;
border-left-style:solid;
border-right-style:solid;
width:17px;
text-align:right;
.DayDropDownList
width:57px;
</style>
<asp:Button ID="btn1" runat="server" Text="Get Some Data" />
<asp:Button ID="btn2" Text="Just post back" runat="server" />
<ig:WebDataGrid ID="wdg1" runat="server" EnableViewState="true" EnableAjax="false" EnableDataViewState="true" AutoGenerateColumns="false">
<Columns>
<ig:UnboundField Header-CssClass="gridHeader" Header-Text="key" Key="f5" Width="75px" />
<ig:UnboundField Header-CssClass="gridHeader" Header-Text="f0" Key="f0" Width="75px" />
<ig:UnboundField Header-CssClass="gridHeader" Header-Text="f1" Key="f1" Width="75px" />
<ig:UnboundField Header-CssClass="gridHeader" Header-Text="f2" Key="f2" Width="75px" />
<ig:UnboundField Header-CssClass="gridHeader" Header-Text="f3" Key="f3" Width="75px" />
<ig:UnboundCheckBoxField Key="Select" HeaderCheckBoxMode="Off" Header-Text="Select" />
</Columns>
<Behaviors>
<ig:EditingCore AutoCRUD="false">
<ig:RowAdding Enabled="true" />
<ig:CellEditing Enabled="true">
</ig:CellEditing>
</Behaviors>
</ig:EditingCore>
<ig:Activation Enabled="true" ><AutoPostBackFlags ActiveCellChanged="false" /></ig:Activation>
<ig:Selection Enabled="true" ><AutoPostBackFlags CellSelectionChanged="false" RowSelectionChanged="true" /></ig:Selection>
<ig:RowSelectors Enabled="true" />
</ig:WebDataGrid>
</div>
</form>
</body>
</html>
<!—End markup -->
'Begin code behind
Public Class WebForm2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub BindData()
Dim dt As DataTable = New DataTable()
Dim dr As DataRow
dt.Columns.Add("f5")
dt.Columns.Add("f0")
dt.Columns.Add("f1")
dt.Columns.Add("f2")
dt.Columns.Add("f3")
dr = dt.NewRow()
dr.SetField(0, 0)
dr.SetField(1, 0)
dr.SetField(2, 0)
dr.SetField(3, 0)
dr.SetField(4, 0)
dt.Rows.Add(dr)
dr.SetField(0, 1)
dr.SetField(1, 1)
dr.SetField(2, 1)
dr.SetField(3, 1)
dr.SetField(4, 1)
dr.SetField(0, 2)
dr.SetField(1, 2)
dr.SetField(2, 2)
dr.SetField(3, 2)
dr.SetField(4, 2)
wdg1.DataSource = dt
wdg1.DataBind()
Private Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn1.Click
BindData()
Private Sub btn2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn2.Click
'do nothing - just post back.
End Class
'End code behind
Also - if you edit any of the other fields as well, they too are maintained only on the first post back.
Hi Dev_01,
I was able to replicate the problem in build 2020. In a later Service Release, build 2064, this issue appears resolved. Could you please upgrade and verify that?
thanks,Dave
Hi
I am also facing the same issue i did the upgrade but still behavior there; I am listing my test application it is very simple I used VS2010, framework 3.5, infragistics version 11.1.20111.2064
At my Aspx page
<
>
<ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="400px" ViewStateMode=Enabled EnableDataViewState=true>
<ig:UnboundCheckBoxField HeaderCheckBoxMode="TriState" HeaderChecked="False"
Key="UnboundCheckBoxField_0">
<Header Text="UnboundCheckBoxField_0" />
</ig:UnboundCheckBoxField>
<ig:UnboundField DataType="System.String" Key="Name">
<Header Text="UnboundField_0" />
</ig:UnboundField>
<Behaviors><ig:EditingCore></ig:EditingCore></Behaviors>
</
ig:WebDataGrid>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
At my code
protected void Page_Load(object sender, EventArgs e)
if
(!IsPostBack)
LoadData();
private void
LoadData()
DataTable table = new DataTable();
table.Columns.Add(
"Name");
table.PrimaryKey =
new DataColumn[1]{table.Columns[0]};
DataRow row = table.NewRow();
row[
"Name"] = "test";
table.Rows.Add(row);
row = table.NewRow();
"Name"] = "test2";
WebDataGrid1.DataKeyFields =
"Name";
WebDataGrid1.DataSource = table;
WebDataGrid1.DataBind();
protected void Button1_Click(object sender, EventArgs e){}
My test is i simply click the header check box now all row check boxes are seleced, i uncheck the first row and press the button to force the post back event
I was expecting to find the last row checked but nope check attached image
Sorry it took me so long to get back - we just now upgraded (To version 11.2.20112.2055).
The row updates and row additions now persist as they should. (A good thing.) However, row deletes do not appear to work. Specifically:
1. Some sample data is bound to the grid.2. The user clicks a row selector.3. The user presses the "Delete" key.4. A post-back occurs but the row is not deleted. It is still present in the grid.
I also tried deleting via javascript and the same behavior occurs.Also, when I put a break-point in the code-behind the "RowsDeleting" event is fired but the "RowDeleted" event is not fired.
In the UltraWebGrid, the row was just deleted from the grid after post-back. And in the WebDataGrid, when using AutoCRUD with a SqlDataSource, rows get deleted as they should.
Is there anything I should be doing differently?
Thanks!
We're experiencing another issue:
When the header checkbox is enabled, the following happens:
1. The user clicks the header checkbox to select all rows.2. The user clicks one or more rows' checkboxes to de-select one or more rows.3. The user posts back.4. The grid is returned with the rows that the user de-selected (unchecked the checkboxes) properly unchecked but with the rows that were supposed to be left checked now returned in a partial state.Rows that were explicitly checked or unchecked as a result of a mouse click do persist across post-backs as they should. Infragistics has an example grid that does not do this. The only difference between the Infragistics example and the project I'm working on is that mine is not bound to a datasource object. Is there something I'm missing?Thanks,
That makes sense. I'll test it out.
Thanks for all your help! I'll close this thread out.
Hi,
I went back and got your sample. Your sample is not quite right. You need to define a PrimaryKey on your DataTable and then a matching DataKeyFields property on the grid for us to delete the row property. dt.PrimaryKey = New DataColumn() {dt.Columns(0)}DataKeyFields="f5"Once I did this, the delete worked fine.