Hello my dear RadGrid friends!
In my project I implemented a RadGrid with a custom data access, nothing like all the examples provided (direct sql, etc.). Here's my NeedDataSource method:
Now I want to get the provided row by in the DeleteCommand, but all I could find was a text-attribute from a cell containing something half-way similar like the DataItem.
Unfortunately, the DeleteCommand's DataItem is empty.
Looks like following:
The part on the bottom, commented out, is my previous try, however, unfortunately the data from the cell is not convertable to the previously generated anonymous type.
Please tell me if you need any further data to provide help.
And also don't hesitate to tell me if I've chosen a wrong/chaotic way to work with the RadGrid ^^
Thanks in advance for your help!
Best
Roman
In my project I implemented a RadGrid with a custom data access, nothing like all the examples provided (direct sql, etc.). Here's my NeedDataSource method:
/// <summary> |
/// Defining the PartnerListGrid's data, i.e. providing a datascource |
/// </summary> |
/// <param name="source"></param> |
/// <param name="e"></param> |
protected void PartnerListGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) |
{ |
PartnerAgent partneragent = new PartnerAgent(); |
Partner[] partners = partneragent.Load(); |
if (!displayMessages(partneragent)) |
{ |
var partnerselects = from p in partners |
select new |
{ |
ID = p.PartnerID, |
Name = p.Name, |
Type = p.Partnertype.Name, |
Contacts = String.Join("<br />", p.Contacts.Select<Contact, String>(cn => String.Concat(cn.Prename, " ", cn.Name)).ToArray()), |
Mainaddress = p.Mainaddress, |
Links = new HyperLink[] { new HyperLink() { Text = "Projekte" }, new HyperLink() { Text = "Passwörter" }, new HyperLink() { Text = "Keys" }, new HyperLink() { Text = "PCs" }, new HyperLink() { Text = "Server" }, new HyperLink() { Text = "Domains" } } |
}; |
PartnerListGrid.DataSource = partnerselects; |
} |
} |
Now I want to get the provided row by in the DeleteCommand, but all I could find was a text-attribute from a cell containing something half-way similar like the DataItem.
Unfortunately, the DeleteCommand's DataItem is empty.
Looks like following:
protected void PartnerListGrid_DeleteCommand(object source, GridCommandEventArgs e) |
{ |
GridDataItem x = ((RadGrid)source).Items[e.Item.ItemIndex]; |
var HereIsSomeDataAvailable = x.Cells[2].Text; |
// HOW??? |
/*var activerow = InformationAgent.CastByExample(x.Cells[2].Text, new { ID = Guid.Empty, Name = "", Type = "", Contacts = "", Mainaddress = "", Links = new HyperLink[] { new HyperLink() { Text = "test" }, new HyperLink() { Text = "test2" } } }); |
PartnerAgent partneragent = new PartnerAgent(); |
partneragent.deletePartner(activerow.ID); |
displayMessages(partneragent);*/ |
} |
The part on the bottom, commented out, is my previous try, however, unfortunately the data from the cell is not convertable to the previously generated anonymous type.
Please tell me if you need any further data to provide help.
And also don't hesitate to tell me if I've chosen a wrong/chaotic way to work with the RadGrid ^^
Thanks in advance for your help!
Best
Roman