Hello,
Regarding the error you received it is caused by the fact that the grid is not populated properly because you have set both DataSource and DataSourceID at the same time. For example if you have assigned your datasource for the grid through NeedDataSource event setting DataSource to empty string on PageLoad should work and the code will looks like the one below:
Additionally, if you want to loop through grid items and delete specific one you need to handle grid PreRender event because pageLoad is too early in the lifecycle and the grid is not populated yet.
Regards,
Pavlina
Telerik
Regarding the error you received it is caused by the fact that the grid is not populated properly because you have set both DataSource and DataSourceID at the same time. For example if you have assigned your datasource for the grid through NeedDataSource event setting DataSource to empty string on PageLoad should work and the code will looks like the one below:
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
RadGrid1.DataSource = String.Empty;
}
}
protected
void
RadGrid1_NeedDataSource(
object
sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = GetDataTable();
}
Additionally, if you want to loop through grid items and delete specific one you need to handle grid PreRender event because pageLoad is too early in the lifecycle and the grid is not populated yet.
Regards,
Pavlina
Telerik
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 Feedback Portal
and vote to affect the priority of the items