This is a migrated thread and some comments may be shown as answers.

RadGrid in a Web Part

4 Answers 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 18 Aug 2010, 09:55 PM

Hi,

I'm creating a web part (with a RadGrid) which implies that there is no designer to assist with development. So all coding is done programatically.

I am displaying records from a SharePoint list and there are too many fields to show all of them in the grid. So I have a RadGrid and a few text fields below it, where I would like to display fields that are not shown in the grid control. My question is simply whether there are any good examples or documentation on how to implement Ajax and/or UpdatePanel programatically. All examples I've found through a fairly extensive search all utilize xml coding.

A related question regarding web parts is where would the xml code need to be added if this is created using xml instead of programatically with C#? An aspx page is not associated with a web part (at least until the web part is added to a page) and I am not aware of an associated ascx file. There is a feature.xml and the xml based .webpart file, but neither of these appear to be the location to add xml code for a web part. I can add this second question as a separate thread if required.

Any assistance would be greatly appreciated.

Regards,

Michael

4 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 19 Aug 2010, 03:35 PM
Hello Mike,

In order to achieve your goal, I suggest that you add a RadAjaxManager control on the website MasterPage. Then you can follow this help topic on how to create ajax-enabled web-part.

Kind regards,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Mike
Top achievements
Rank 1
answered on 19 Aug 2010, 06:46 PM
Hello again Iana,

Thanks for responding to the second part of my inquiry. I will follow your instructions regarding the RadScriptManager and the help topic. If I run into anything that does not make sense or gives me difficulty, I will let you know. Otherwise, I'll drop back and mark this as answered.

Regards,

Michael
0
Mike
Top achievements
Rank 1
answered on 25 Aug 2010, 07:58 PM
Hi Iana,

I have been following the instructions as provided by http://www.telerik.com/help/aspnet-ajax/create-ajax-enabled-sharepoint-webpart-radcontrols.html, however, I am receiving an error message "The control with ID 'pnlUpdate' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.". I have added my controls in the OnLoad method and added the appropriate registering of the startup script and ScriptManager in the OnInit method as recommended by the help page linked above.

The pnlUpdate control is an UpdatePanel. What I am trying to accomplish is the loading of some text boxes with values that are not displayed directly in the RadGrid control. Should I be using UpdatePanel? Or is there some other way of updating fields without redrawing the entire page?

Btw, I have not found an easy way of fetching the field values for a given selected row within the RadGrid. If you know of a good example to point me toward, I'd appreciate it. I find the volume of information a bit much to deal with efficiently and often find several ways to do things when I search the Telerik documentation, forums and blogs. My main issue with finding appropriate guidance is that I'm coding a web part for SharePoint 2007.

Regarding the error above, here is a snippet of the OnLoad method showing the control that requires the ScriptManager.

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    pnlUpdate = new UpdatePanel();
    pnlUpdate.ID = "pnlUpdate";
    pnlUpdate.UpdateMode = UpdatePanelUpdateMode.Conditional;
    // The RadGrid Incident List control...
    rgdIncidentList = new Telerik.Web.UI.RadGrid();
    rgdIncidentList.Width = Unit.Pixel(1193);
    rgdIncidentList.GridLines = GridLines.Vertical;
    rgdIncidentList.ShowHeader = true;
    rgdIncidentList.HorizontalAlign = HorizontalAlign.Center;
    rgdIncidentList.SelectedIndexChanged += new System.EventHandler(rgdIncidentList_SelectedIndexChanged);
    rgdIncidentList.NeedDataSource += new GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
    pnlIncidentList = new Panel();
    pnlIncidentList.ID = "pnlIncidentList";
    pnlIncidentList.Controls.Add(rgdIncidentList);


Many thanks,

Michael
0
Iana Tsolova
Telerik team
answered on 30 Aug 2010, 01:46 PM
Hello Mike,

Could you please confirm you added a ScriptManager or RadScriptManager in the OnInit handler of the web part?
Regarding the ASP:UpdatePanel usage: You can use RadAjaxManager instead in order to achieve your goal. For that purpose add an ajax setting where the grid updates the outer content. However a scenario with an UpdatePanel is also valid so you should choose the approach preferred by you.
Additionally, RadGrid has a SelectedValue property which holds the DataKeyValue of the selected item. Can you check it out and let me know if it works for you.

Kind regards,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Mike
Top achievements
Rank 1
Share this question
or