iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
On my grid I have a RowChecker column. A user will select one or more rows to do some action. A button is clicked and all checkedrows are found and processed. At the end the CacheDataSource is cleared and then rebind the grid. This all works fine. The problem now occurs when the user attempts to select another row and run the process again. When I look at what is returned from the getCheckedRows funtion is the new record selected as well as the row selected in the previous selection, but since that previous record is no longer in the grid and error occurs.
How can I clear the CheckedRows between postbacks on server side? I've tried GetCheckedRows().clear but that didn't seem to work.
Hello,Thank you for waiting.I set AllowGrouping property to “Yes” and I add a couple line of code in button click event to get the ContactName column value.Here’s the example snippet code:
object objKeyValue = keyValue as object;TextBox1.Text += WebGrid1.RootTable.GetUngrouppedRows().GetRowByKeyValue(objKeyValue).Cells.GetNamedItem("ContactName").Text + "\n";
Hope this helps. Thank you.Regards,Hans.
Hello,Perhaps you could try to set the PersistRowChecker property to "false". It will automatically clear all checked rows after post back process.Hope this helps.Regards,Hans.
Nope it doesn't clear the checked rows. It clears them from the Grid but if you look at the CheckedRows collection the previous selections are still there.
Hello,I have tried to modify one of WebGrid samples, RowCheckerColumn.aspx page.I set the PersistRowChecker property to “false”. I also modified the validation code in button click server side event.The result is there is no checked row collection any more after post back process.I attached two video about what I get on my end.The first video is the result when I set the PersistRowChecker property to “false” and the second is the result when I set the PersistRowChecker property to “true”.Please kindly have review on the modified sample as well. To run the sample, just simple add the sample to WebGrid Samples solution.Please correct me if wrong. Thank you.Regards,Hans.
I'll take look at your project and get back to you.
Your project works but mine doesn't but is more complex than your. I have no idea what it causing the problem. Not sure where to look, but this is killing my projects.
This is my grid settings.
<ISWebGrid:WebGrid ID="WebGrid1" runat="server" Height="320px" UseDefaultStyle="True" Width="100%" DataCacheStorage="Session" EnableViewState="true" ViewStateStorage="PageCache" EnableSection508Standards="False" RenderingMode="XHTML" EnableWebResources="Always"> <LayoutSettings AllowFilter="Yes" AllowGrouping="Yes" AllowSorting="Yes" PagingMode="VirtualLoad" VirtualLoadMode="Default" GroupByBoxVisible="False" AllowColumnFreezing="No" AllowColumnMove="Yes" AllowExport="Yes" AlwaysShowHelpButton="false" AllowSelectColumns="Yes" RowLostFocusAction="NeverUpdate" AutoFilterSuggestion="True" FilterBarVisible="false" HideColumnsWhenGrouped="No" InProgressUIBehavior="ChangeCursorToHourGlass" PagingSize="25" ShowFilterStatus="True" RestoreRowSelection="RootTableOnly" VirtualPageSize="25" PagingExportMode="ExportAllData" AllowMultipleSelection="No" GroupRowInfoFormatDefault="[caption] : [value] ([count])" ColumnFooters="No" HeaderClickAction="SortSingle" ShowColumnAction="true" RowHeaders="No" CellClickAction="CellSelect" AutoFitColumns="false" PersistRowChecker="false"> <FreezePaneSettings ShowInContextMenu="false" MaxFrozenColumns="1" AbsoluteScrolling="True" /> <ClientSideEvents OnAfterInitialize="OnAfterInitialize" OnUnhandledError="WebGrid1_OnUnhandledError" OnResponse="doLoad" /> <AlternatingRowStyle Font-Names="Verdana" BackColor="#ECE9D8" Font-Size="8pt" HorizontalAlign="Center" /> <RowStyle Font-Names="Verdana" Font-Size="8pt" HorizontalAlign="Center" BackColor="#c9c9c9" /> <FooterStyle Font-Names="Verdana" BorderSettings-Left-Color="White" BorderSettings-Top-Color="White" > <BorderSettings> <Left Color="White" /> <Top Color="White" /> <left color="White" /> <top color="White" /> </BorderSettings> </FooterStyle> <StatusBarStyle BaseStyle="Normal" Font-Bold="True" Font-Size="9pt" BackColor="#b5d4eb"> </StatusBarStyle> <TextSettings> <TextItems> <ISWebGrid:WebGridTextItem TextItem="CommonText/Refresh" TextValue="Refreshing Carriers" /> <ISWebGrid:WebGridTextItem TextItem="CommonText/NoData" TextValue="There are no Carriers to display, modify the filters above to view Carriers" /> </TextItems> </TextSettings> </LayoutSettings> <RootTable Caption="Carrier Information" TableHeaderVisible="False" DataKeyField="DOT_NUMBER"> <HeaderStyle BackColor="#3d4351" BorderStyle="Solid" BorderWidth="1px" Wrap="true" Cursor="Hand" Font-Names="Verdana" Font-Size="8pt" ForeColor="White" Font-Bold="true" HorizontalAlign="Center" CssClass="WG5-Header" CustomRules="height:auto"> <BorderSettings> <Left Color="#3d4351" /> <Top Color="#3d4351" /> <Bottom Color="#3d4351" /> </BorderSettings> </HeaderStyle>
This is the button click code: The first time is fine, if I select other records after postback, the count of CheckedRows includes the records from the first attempt. This is also occurring when using a group by. I am also filling the gris using the InitalizeDataSource event. Any ideas? Is jQuery inteferring?
Protected Sub btnAssign_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAssign.Click If Page.IsValid Then Dim checkedRows As ArrayList = WebGrid1.RootTable.GetCheckedRows() Dim textValue As String = String.Empty Dim dot_number As String = String.Empty Dim entry_date As String = String.Empty Dim ostate As String = String.Empty Dim day_90_date As String = String.Empty Dim audit_type As String = String.Empty Dim offsite_eligable As String = String.Empty Dim carrier_name As String = String.Empty Dim ne_status As String = String.Empty Dim ne_exit_date As String = String.Empty Dim success As Boolean = False Dim i As Integer = checkedRows.Count For Each keyValue As String In checkedRows dot_number = keyValue carrier_name = WebGrid1.RootTable.Rows.GetRowByKeyValue(keyValue).Cells.GetNamedItem("CarrierName").Value entry_date = WebGrid1.RootTable.Rows.GetRowByKeyValue(keyValue).Cells.GetNamedItem("EntryDate").Value ostate = WebGrid1.RootTable.Rows.GetRowByKeyValue(keyValue).Cells.GetNamedItem("OICState").Value day_90_date = WebGrid1.RootTable.Rows.GetRowByKeyValue(keyValue).Cells.GetNamedItem("Day90Ltr").Value.ToString audit_type = WebGrid1.RootTable.Rows.GetRowByKeyValue(keyValue).Cells.GetNamedItem("AuditType").Value.ToString offsite_eligable = WebGrid1.RootTable.Rows.GetRowByKeyValue(keyValue).Cells.GetNamedItem("OffsiteEligable").Value.ToString ne_status = WebGrid1.RootTable.Rows.GetRowByKeyValue(keyValue).Cells.GetNamedItem("NEStatus").Value.ToString ne_exit_date = WebGrid1.RootTable.Rows.GetRowByKeyValue(keyValue).Cells.GetNamedItem("ExitDate").Value.ToString success = AssignCarrier(i, dot_number, ostate, entry_date, day_90_date, audit_type, offsite_eligable, carrier_name, ne_status, ne_exit_date) Next ' clear the insput field clearFields() ' rebind grid 'WebGrid1.RootTable.GetCheckedRows().Clear() WebGrid1.ClearCachedDataSource() WebGrid1.RebindDataSource() ' This forces a rebinding of the grid, not a very good way but appears the CheckedRows are not cleared out! 'Response.Redirect("~/SA/unassigned.aspx", True) End If End Sub
Well, I was able to fix the problem. I had RestoreRowSelection set to RootTable, so the Row Checker field was always set. Disabling RestoreRowSelection fixed this problem. But another problem occurred and can be seen using your sample, with a slight modificiation.
On the webgrid add AllowGrouping="Yes" to the Layout settings. in the code behind right below the
TextBox1.Text += keyValue + "\n";
add this line
object x = WebGrid1.RootTable.Rows.GetRowByKeyValue(keyValue).Cells.GetNamedItem("ContactName").Value;
Open the page in the browser, Group by the City field, select a row and then click on button. You will get an error on this new line, saying object reference is not set. I need to get a value from the gird when I click on the button when Grouped By. Any ideas?
Again this onl
Hans,
Thank you, works great. This functionality is a big asset for this web application.
john
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname