Hi there,
I got a wierd problem on RadGrid when using inside a dynamically loaded (using LoadControl) Usercontrol. the sorting not seems to work properly. I intially got this error
$WebAnalytics$ReportViewer1$GeneralSummary1$rgGeneralSummary$ctl01$ctl02$ctl01$ctl03' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events to avoid this error.
I am using the NeedDataSource to assign the datasource (without calling databind). Here is the declaration of the RadGrid.
<rad:RadGrid ID="rgGeneralSummary" runat="server" GridLines="None" AllowPaging="True"ShowStatusBar="true" PageSize="20" RadControlsDir="~/Resources/RadControls/" Skin="WebBlue" SkinID="WebBlue" SkinsPath="~/Resources/RadControls/Grid/Skins" AllowSorting="True" CellSpacing="10" CellPadding="5" AllowFilteringByColumn="false" ShowGroupPanel="True" Width="650px" AutoGenerateColumns="False" EnableAJAX="true" EnableAJAXLoadingTemplate="true" Height="250px" OnNeedDataSource="rgGeneralSummary_NeedDataSource">
<ClientSettings AllowDragToGroup="False">
<Scrolling AllowScroll="True" UseStaticHeaders="True" /></ClientSettings>
<PagerStyle PagerTextFormat="<strong>{5} Records</strong>. Change page: {4} &nbsp;|&nbsp; Displaying page {0} of {1}, items {2} to {3} of {5}." />
<MasterTableView AutoGenerateColumns="False" AllowFilteringByColumn="false" DataSourcePersistenceMode="ViewState">
<Columns>
<rad:GridBoundColumn DataField="Period" DataType="System.String" HeaderText="Period" SortExpression="Period" UniqueName="Period" ItemStyle-Width="130px" HeaderStyle-Width="130px">
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="PageViews" DataType="System.Int32" HeaderText="PageViews"ItemStyle-Width="130px" HeaderStyle-Width="130px" ReadOnly="True" SortExpression="PageViews" UniqueName="PageViews">
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="Sessions" DataType="System.Int32" HeaderText="Sessions"ItemStyle-Width="130px" ReadOnly="True" HeaderStyle-Width="130px" SortExpression="Sessions" UniqueName="Sessions">
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="UniqueVisitors" DataType="System.Int32" HeaderText="Unique Visitors"
ItemStyle-Width="130px" HeaderStyle-Width="130px" ReadOnly="True" SortExpression="UniqueVisitors" UniqueName="UniqueVisitors">
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="ViewsPerSession" DataType="System.Decimal" HeaderText="Page views per session" ItemStyle-Width="130px" HeaderStyle-Width="130px" ReadOnly="True" SortExpression="ViewsPerSession" UniqueName="ViewsPerSession">
</rad:GridBoundColumn>
</Columns>
</MasterTableView>
</rad:RadGrid>
Later i checked this post and introduced ItemCreated to set the Header links Id. This avoids the exception but issue still there. The sorting works fine in ascending order but the decending order is not working.
Please help me to fix this sorting issue.
My Problem: The update command (and insert command) is not refreshing the grid. I have a problem with both insert and update, but for this post lets just focus on update.
My Code:
I have a data grid (residing on a tab).
I am using InLine Edit Mode, with no column templates.
When the user edits the row and later clicks the Update command, I execute my OnUpdateCommand() method. In this method, I successfully pull the user inputs, execute the SQL updates. All is good.
The inline edit, goes away, but the user does not see the data grid reflect the update.
Now the user can hit the refresh data grid command, and that will work.
I then attempted to execute the same refresh command after the OnUpdateCommand had done it's work, but still no grid refresh.
Why I am Picking-On the OnUpdateCommand:
| OnUpdateCommand="grdAltProductCodes_UpdateCommand" |
I went to the grid's mark up, removed the OnUpdateCommand attribute. The result is that the user
So everything is fine, till I attempt to use the OnUpdateCommand. Then no grid refresh.
So what does my OnUpdateCommand have to do, to force the data grid to refresh?
Is there a good, simple demo available? Everything I found was for the automatic updates.
Also, I did grabbed the latest code as of yesterday.
Thank You!
| protected void grdAltProductCodes_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) | |
| { | |
| AlternateProductCodeDC altProductCode = new AlternateProductCodeDC(); | |
| //The GridTableView will fill the values from all editable columns in the hash | |
| GridEditableItem editedItem = e.Item as GridEditableItem; | |
| Hashtable newValues = new Hashtable(); | |
| e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem); | |
| //Set Primary Key Stored as a Delimited Value within the Query String | |
| string[] selectedRecord = Request.QueryString["i"].Split(','); | |
| this._presenter.OnViewInitialized(Int32.Parse(selectedRecord[0]), selectedRecord[1], selectedRecord[2], selectedRecord[3], DateTime.Parse(selectedRecord[4])); | |
| altProductCode.MasterCompanyId = Int32.Parse(selectedRecord[0]); | |
| altProductCode.CountryCode = selectedRecord[1]; | |
| altProductCode.Jurisdiction = selectedRecord[2]; | |
| altProductCode.ProductCode = selectedRecord[3]; | |
| //Read user values | |
| altProductCode.AlternateProductCode = Convert.ToString(newValues["Alternate_Product_Code"]); | |
| altProductCode.EffectiveDate = Convert.ToDateTime(newValues["Effective_Date"]); | |
| if (newValues["Obsolete_Date"] == null) | |
| { | |
| altProductCode.ObsoleteDate = null; | |
| } | |
| else | |
| { | |
| altProductCode.ObsoleteDate = Convert.ToDateTime(newValues["Obsolete_Date"]); | |
| } | |
| //Have the presenter update the database | |
| _presenter.OnAlternateProductCodeUpdate(altProductCode); | |
| //Somehow get the datagrid to refresh itself | |
| //RefreshGrid(); | |
| //e.Canceled = false; | |
| } |
I am placing the combobox in a user control and the user control inside a content page which is inherits from a master page. I placed a script manager in the master page. My sample application is ASP.NET 2 AJAX-Enabled.
The problem is when I click on any tree node the combobox text is not getting the node text value and also the tree view is not disappearing after selection of the node.
Please how can I resolve this problem?
| protected void grdVariableLst_ItemCreated(object sender, GridItemEventArgs e) |
| { |
| if (e.Item.OwnerTableView.Name == "Variables") |
| { |
| if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem) |
| { |
| GridDataItem item; |
| item = (GridDataItem)e.Item; |
| if (int.Parse(((System.Data.DataRowView)(e.Item.DataItem)).Row.ItemArray[4].ToString()) == 1) |
| { |
| item["DeleteColumn"].Text = "Delete"; |
| } |
| } |
| } |
| } |
The problem is that the javascript code in GridSelection.js does not handle the case where a grid is contained by a runat="server" control AND it's ID begins with an underscore. In this case, the generated ID has two underscores next to each other in the generated client id. And throughout GridSelection.js, there are lines such as:
|
if( el.id.split("__").length == 2 ) |