E-mail
Whilst using Telerik’s CMS SiteFinity (see other blog posts) I started to use their RadGrid.
So why use these third party components? According to Telerik:
“…help you build high-quality, professional line of business web applications. …maximizing productivity and creating rich, SEO-friendly, high-performance Enterprise web applications.”
Their Grid is USD999, and has combined questions in their forums of 100,000 on the grid (over asp.net and asp.net ajax). It is their most popular control.
So what can it do? Here is an example showing LinqToSQL as the ORM
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/linqdatasource/defaultcs.aspx
http://tv.telerik.com/radtips/episode/using-the-linqdatasource-in-your-radgrid
Got some issues with errors and internal server errors on my shared host.
<customErrors mode="off"/>
Theme: Web Blue
Drop Down: link to CountryID, a new data Source
Data Editing: AllowAutomaticDeletes, Inserts, Updates
Paging: PageSize = 20
MasterTableView, EditMode, InPlace
and can edit the country as well with a drop down.
Date – used {0:d} to only get the date
Cost:
Using a RadComboBox:
Chosen the datasource, and DataText field = name and DataValueField = countryid
AutoPostBack = true
Put a conditional on the original linked data source.
It all works as expected.
Uploading to live
Project is now: TestRadGridTelerik3… uploading to radgrid2 on server
Mastertable view, CommandItemDisplay = top
I want to be able to insert into the grid, based on my logged in user. So have to manually hook into the events
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/programaticlinqupdates/defaultcs.aspx
http://www.telerik.com/help/aspnet-ajax/grdlinqtosqlmanualcrudoperations.html
Using TestRadGridTelerik3 project, addSmart.aspx
<telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="False" AllowPaging="True" OnNeedDataSource="RadGrid1_NeedDataSource" OnUpdateCommand="RadGrid1_UpdateCommand" OnItemCreated="RadGrid1_ItemCreated" OnDeleteCommand="RadGrid1_DeleteCommand" OnInsertCommand="RadGrid1_InsertCommand" GridLines="None">
<telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" />
Very nice goodness baked in for delete
protected void RadGrid1_DeleteCommand(object source, GridCommandEventArgs e) { var raceId = (Guid) ((GridDataItem) e.Item).GetDataKeyValue("RaceID"); //retrive entity form the Db var race = DbContext.races.Where(n => n.raceid == raceId).FirstOrDefault(); if (race != null) { //add the category for deletion DbContext.races.DeleteOnSubmit(race); try { //submit chanages to Db DbContext.SubmitChanges(); } catch (Exception) { ShowErrorMessage(); } } }
There is a double click event on the row.. which goes into edit mode. This is wired up in JavaScript.
Getting nice js numeric error checking on the input for money and distance.
Have got delete working
**Update doesn’t work
**Insert doesn’t work
**The error message don’t show up properly.
**changed teh db structure locally for race to allow nulls for categoryid… maybe vioates an FK constraint.?? see profiler?
Found that I couldn’t understand what was happening. So went back to the example code by Telerik on: http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/programaticlinqupdates/defaultcs.aspx
Ripped out the code, made a simple LinqToSQL class against 1 table only (Products). Got it working locally:
this is called RadGrid4Telerik.
Next step is to get my example of races working with 1 table only (just like this). Problem with taking this live is that Northwind is quite a large db and complex and I’ve got average hosting! Also very good to bring back to basics.
Remember Me
a@href@title, strike