Telerik Forums
UI for ASP.NET AJAX Forum
0 answers
178 views
Hi,

I'm having some issues with RadGrids created dynamically in the code behind. Here's an explanation of the situation:

I have a static RadGrid defined, let's call it "MainRadGrid", as well as a static formview below it. When I click on a row inside this radgrid, I fill out the formview with data depending on the row selected in the MainRadGrid. There's a RadAjaxPanel around these controls.

Some of the fields inside this formview are created dynamically. This includes several RadGrids that use their own ObjectDataSources with corresponding select, insert, and delete methods, as well as Automatic Inserts and Deletes enabled. Till now, everything is fine.

My page has an "Edit" button that puts the formview in edit mode. I click it, and everything goes into edit mode, including my dynamic radgrids (editmode = inplace, and all rows editable). All fine till now as well.

My issue occurs when I click on the "Add" button of the dynamic radgrids. At that point, I get an exception, which is the following:

Sys.WebForms.PageRequestManagerServerErrorException: Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

---
More explanations:
I catch the RowClicked command in the MainRadGrid_ItemCommand event. At that point, I retrieve a couple of values from the selected row and store them in the page's viewstate and then bind the formview.
I need these values to be able to load the correct data and dynamic fields into the formview. From my understanding, this is too late because the viewstate has already been loaded, which causes my issue mentioned above.

Any help with this issue?

---

I tried disabling the viewstate for my FormView. This fixes the issue mentioned above, but causes another one. Basically, the InitInsert command works fine when  I click on the "Add" button, but when I input values in the row generated then click on insert, the RadAjaxPanel mentioned earlier does its thing and the new row that was supposed to be added disappears instead, and the ObjectDataSource insert method is never called. The dynamically added RadGrid also goes back into readonly mode and does not take into consideration the EditIndexes.

So that's another issue.

---
To summarize:
1. I have a MainRadGrid and a FormView. I select a row in the RadGrid and databind the formview.
2. The formview creates dynamic controls depending on the row selected, including dynamic RadGrids that are connected to their own ObjectDatasources. This is done in the FormView_ItemCreated event.
3. I go into edit mode, and then attempt to add a new row to the dynamic RadGrids, and I get a viewstate error. If I disable the viewstate, the added row is there but when i click insert, the row disappears and the grid is not in edit mode anymore.

This is long, I know, but i hope you got this far. I will attempt to post sample code if possible.
blablabla
Top achievements
Rank 1
 asked on 03 Oct 2011
1 answer
208 views
I have change the style fot the rows + alt rows in the aspx not by CSS
but it is not working though I could change the grid header font and size but cant change its back color
in rows+ alt rows nothing only the horizontal alignment works nothing else working
what  am I doing wrong?

 

<HeaderStyle BackColor="#004000" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Font-Size="XX-Small" ForeColor="Black" HorizontalAlign="Center" />

 

 

<ItemStyle BackColor="#E0E0E0" Font-Size="XX-Small" ForeColor="SpringGreen" HorizontalAlign="Center" />

 

 

<AlternatingItemStyle BackColor="Silver" Font-Bold="False" Font-Names="Arial" Font-Size="XX-Small"

 

 

ForeColor="RosyBrown" HorizontalAlign="Center" />

 


Ahmed
Pavlina
Telerik team
 answered on 03 Oct 2011
2 answers
177 views
I have a simple RadSplitter page with a variable number of panes; in each pane, a local ASPX page is rendered that shows a map of the UK with a graph of data overlaid on top.  The map is the same for every pane but the graphs of data vary: e.g., in the first pane I have data from 1983, in the second data from 1990, and so on.  I am constructing the RadSplitter (rsMaps) on the server like this:

// add a new pane (in the splitter) for each map
for (int i = 0; i < _numMaps; i++)
{  
    if (i > 0)
    {
        // add splitter-bars in between each map
        RadSplitBar rsb = new RadSplitBar();
        rsMaps.Items.Add(rsb);
    }
    RadPane rp = new RadPane();
    // set URL
    rp.ContentUrl = _mapUrlBase + Request.QueryString["URL" + i.ToString()] + "&MultiMap=true&Title=" + Request.QueryString["Title" + i.ToString()];
    rsMaps.Items.Add(rp);
}

So far so good -- the URL of each pane is read from the Request string (of the page containing the RadSplitter) and the content is subsequently loaded.  However, the data graphs are getting mixed up!  The results are random but generally what happens is that two of the panes will show the same graph (e.g. for 1983) and some graphs will not be shown at all (e.g. 1990).  I think this is because the panes are loaded simultaneously (in parallel) and that the page is becoming confused somehow.  Therefore I wanted to try loading the panes in sequence (so that one pane must have finished loading before the next one starts) rather than in parallel, to see if that might fix it.

My question, then, is as follows: Can I set the content URLs on the client and force the panes to load one at a time?  I was trying to do something like this, where the OnClientLoaded event of the RadSplitter is handled by the function below:

function LoadPanes(sender)
{
  var rsMaps = sender;
  var panes = rsMaps.getPanes();
  for (var i = 0; i < panes.length; i++)
  {
    var pane = panes[i];
    var contentUrl = getContentUrl(i); // this would come from the Request String
    pane.set_contentUrl(contentUrl);
    // >>>> PSEUDO-CODE: this is the bit I'd like to do <<<<
    while (!pane.HasFinishedLoading)
    {
       sleep(1000);
    }
  }
}

Any insights would be gratefully received!

Ed Graham
Ed
Top achievements
Rank 1
 answered on 03 Oct 2011
11 answers
213 views
Hi

I was here to find a solution for TimeZone when Server and client are at different locations.
The problem i am trying here to solve is that if I am in UK and Servers are in USA, then when i set a reminder to 5pm
it should popup reminder as per UK 5pm and not as per USA 5pm.

I guess there is a feature to manage this and when i tried to look at URL
http://demos.telerik.com/aspnet-ajax/scheduler/examples/timezones/defaultcs.aspx

It redirects me to http://demos.telerik.com/ErrorPageResources/error.aspx?aspxerrorpath=/aspnet-ajax/scheduler/examples/timezones/defaultcs.aspx

So I guess the link is not working.   Can anyone look into it.   and is there any other detail article/tutorial on the topic.

-JD
Peter
Telerik team
 answered on 03 Oct 2011
3 answers
142 views
I've got a treeview with checkable nodes. I'm trying to keep a count of how many are checked and I'm using the OnClientNodeChecking call to do so. Here is my function:

function UpdateTotal(sender, eventArgs) {
            var node = eventArgs.get_node();
            var pnode = node.get_parent();
 
            var attribs = pnode.get_attributes();
            var cnt = attribs.getAttribute("Count");
             
            if (!node.get_checked()) {
                cnt++;
            } else {
                cnt--;
            }
            attribs.setAttribute("Count", cnt);
//            var cnodes = pnode.get_nodes();
//            var cnt = 0;
//            for (var i = 0; i < cnodes.get_count(); i++) {
//                if (cnodes.getNode(i).get_checked()) {
//                    cnt++;
//                }
//            }
 
           pnode.set_text(attribs.getAttribute("DefaultName") + ' (' + cnt + ')');
        }

However, I noticed when I click the checkbox quickly, the event does not get called and therefore the counts are incorrect. Here is a video displaying the issue.

http://screencast.com/t/1FkFLNDk6

You'll notice when the screen first loads, the count is correct. If I click the checkbox, the count changes correctly. But if I double-click a checkbox, the count is not longer in sync. When the box is checked, it shows 4, when it's unchecked it shows 5, but it should be the other way around. I've also noticed that when I do a postback and check the state of the node in the code behind, it does not reflect what is being on the screen. Basically, the number that you see next to the parent node correctly corresponds to the number of nodes the treeview believes are checked when it gets to the code behind. However, what is displayed does not match with what the treeview actually thinks is checked.

Hopefully that makes sense,
Adam
Plamen
Telerik team
 answered on 03 Oct 2011
1 answer
95 views
Hi,  I am trying to design a function to delete a node from treeview by drag and drop.  I put the RadTreeview inside a panel with shaded background.  I created another trash panel next to it.  When I dragged the node into the trash panel, the server side node_drop event fired and everything was good.  However, what I really want is when I drag the node outside the shaded area, the server side node_drop event can be fired.  Is there a way to achieve that?

Thanks!
Tim
Plamen
Telerik team
 answered on 03 Oct 2011
7 answers
292 views

Hi all, I know this a more a general .NET question, but hopefully someone can help.
I've got a service that simply returns a string, which i use to populate the Tooltip.

Runs all fine locally through the IIS development environment, but when i deploy it on my server to run through IIS it errors.

Initially the error was due to be not having <webServices> reference in my web.config.

I've now added that in and am getting a different error.

I've limited it down to this line:

    <WebMethod()> _
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Function GetDataByRegion(ByVal context As Object) As String

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
   at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
   at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)

If it's not specified the service seems to return XML ok.

Whats going on ?
Marin Bratanov
Telerik team
 answered on 03 Oct 2011
6 answers
186 views
Hi,
i am retrieving treeview node text value with your example.but i want to also get selected node value..and i dont have any opinion how can i get multiple value when i use checkbox property true on treeview.Can you show me the way please?
I get the text like this.

<script type="text/javascript">
    function nodeClicking(sender, args) {
        var comboBox = $find("<%= cbxDepartments.ClientID %>");

        var node = args.get_node()

        comboBox.set_text(node.get_text());


        comboBox.trackChanges();
        comboBox.get_items().getItem(0).set_text(node.get_text());
        comboBox.commitChanges();

        comboBox.hideDropDown();

        // Call comboBox.attachDropDown if:
        // 1) The RadComboBox is inside an AJAX panel.
        // 2) The RadTreeView has a server-side event handler for the NodeClick event, i.e. it initiates a postback when clicking on a Node.
        // Otherwise the AJAX postback becomes a normal postback regardless of the outer AJAX panel.

        //comboBox.attachDropDown();
    }

    function StopPropagation(e) {
        if (!e) {
            e = window.event;
        }

        e.cancelBubble = true;
    }

    function OnClientDropDownOpenedHandler(sender, eventArgs) {
        var tree = sender.get_items().getItem(0).findControl("tvDepartments");
        var selectedNode = tree.get_selectedNode();
        if (selectedNode) {
            selectedNode.scrollIntoView();
        }
    }
    </script>
Ivana
Telerik team
 answered on 03 Oct 2011
3 answers
187 views
I have an Aspx page with tabstrip having RadMultiPageView control having 4 tabs on the page and various telerik/.net controls like dropdonw,RadAsynchronusUpload, textbox etc on each tab.In RadAsynchronus Upload i Validated with File Extension Filtration.But it is not Validated so that i can select any filetypes.currently it is in second tab,and selected tab index is 0.if i place it in first tab it is working.i Don't know where i went wrong.Any Help would be Appreciated.
Thanks
jobin
Peter Filipov
Telerik team
 answered on 03 Oct 2011
5 answers
245 views
HI forum!

I m having a problem with the

 

Protected Sub RadScheduler1_AppointmentClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.SchedulerEventArgs) Handles RadScheduler1.AppointmentClick, it only fires when i do double-click witch also fires the edit appointment. is it not supposed for only one click on an appontment for this event fire?

Many thanks FEST

 

Plamen
Telerik team
 answered on 03 Oct 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?