How to remove the viewstate of a Control programmatically? - viewstate

I have a control, RadGrid, for which viewstate should stay enabled.
Only when a condition is met, a button is clicked, the viewstate of that control should be removed so that the new values are bound to this control.
How to remove the viewstate of a Control programmatically?
Many thanks,

You can remove an item from ViewState with:
ViewState["controlName"] = null;
However, after this, you will need to recreate the control and re-add it to the page, else your ViewState will not match your control tree.

Related

How to Asynchronously Show a Create New Button On a CRM Sub Grid?

I need to hide the "Add New" button on a sub grid until certain criteria are met. Calling Xrm.Page.ui.refreshRibbon will trigger my JS function defined in my Enable Rule, but I can't get the + button to show up.
Is this unsupported, or is there some methodology to get this to work?
Seems like you have to do few extra trick.
Refreshing the subgrid command bar
You will find that when the form is loaded, if there is a value in the attribute you have referenced in your enable rule, the Add New button will be visible. If however the value changes, the sub-grid command bar will not automatically refresh to reflect the new state. Upon adding or deleting rows in the sub-grid the command bar is refresh – but this isn’t much use in this case.
The main form command bar can be refreshed using Xrm.Page.ui.refreshRibbon() however this will not refresh sub-grid command bars. Instead, we can add an onchange event to the fields that are used in our VaueRule and call:
Xrm.Page.data.save();
This will refresh the sub-grids and re-evaluate any of the EnableRules however it will also save any other dirty attributes and so should be used with caution if you do not have auto-save enabled.
Ref: https://ribbonworkbench.uservoice.com/knowledgebase/articles/489288-show-or-hide-the-add-new-button-on-form-sub-grid
Arun Vinoth did find a great article to describe the issue, but actually I've found that just calling refresh on the grid itself was all that was actually required.
It's important to note, that this does not re-run the enable rules, just shows the button if the state has changed.

drop down list selected index changed event handler in User Control

I have a UserControl:'TestControl' - which has one DropDownList: 'TestDDL' and a TextBox: 'TestAdditionalNotes' (there are no buttons or anything else in the Control that will cause a post back - and I don't need a postback as most of the data is client side). I have written a event handler for onSelectedIndexChange event in the Control. This control will be used in a 'Repeater Control' - Now I have a Testpage: 'Test.aspx' I have registered this user control on the test page - now what I want : When I change the DropDown list selected item in the contorl - the textbox should be visible/in visible based on my selection. But how to trigger the evenhandler on the control from the test page ?
I solved the problem... my code and the handlers where correct... it was just on that particular test page some javascripts libraries missing - which are required by the telerik rad control i.e the dropdown list... once I added those files manually... everything works...
(I figured this out by trying the control on a different page and the event was being raised).... Thanks

kendo ui grid looses selection when bound value changes

It seems like the grid widget looses selection when a value that a column is bound to is changed. Does anyone know how to not loose the selection?
Example here (select a row then click "click here"):
http://jsbin.com/oyuher/1/edit
Yes, the Grid is refreshed and any selection is lost. In this code library you can get the idea how to persist the selection.
Basically there is a cookie which is used but since you do not reload the page you can simply safe it into a JavaScript variable.

how to maintain scroll state between posts in MVC3

how to maintain the scroll state when Telerik grid Edit button is cliked.
You will have to capture the current scroll position with javascript and then store it on a hidden field, then on your action create a javascript to return the user to the same position and print it in the view so that it gets executed, that's how webforms does it.

RadCombobox doesnot maintain selected item

I have binded RadCombo on LoadonDemand Event. when i change page of radgrid, RadCombo looses its selected item.
How to maintain RadCombo selected item.
Please Help
Have you tried using the RadComboBox's trackChanges() and commitChanges() methods to preserve the selected item across post-backs?
http://www.telerik.com/help/aspnet-ajax/combobox-client-side-radcombobox.html
I'm assuming the RadGrid is not contained in a RadAjaxPanel because if it were this would be taken care of automatically through partial page rendering (i.e. only the RadGrid would be re-rendered when paging occurs). It would probably be helpful if you could post you page's markup.
When you page the grid is rebound and the controls inside it are recreated. To keep the combobox selection, save it Cache of Session object and then recover it from there wiring the PageIndexChanged event of the grid.

Resources