I created a RadGrid programmatically, and i use the following lines:
RadGrid2.NeedDataSource += new GridNeedDataSourceEventHandler(RadGrid2_NeedDataSource);
instead of --->
RadGrid2.DataSourceID = "SqlDataSource1";
i want to create a GridTableView like the above line
GridTableView tableViewOrders = new GridTableView(RadGrid2);
¿¿ what should be the declaration to replace ----> tableViewOrders.DataSourceID = "SqlDataSource2"; ???
i think somesthing like --->
tableViewOrders.NestedViewSettings.DataSourceID += new GridNestedViewSettings(RadGrid3_NeedDataSource);
but it is incorrect.
tableViewOrders.DataKeyNames =
new string[] { "idCodigos" };
GridRelationFields relationFields = new GridRelationFields();
relationFields.MasterKeyField =
"idCodigo";
relationFields.DetailKeyField =
"idCodigoSubGrupo";
tableViewOrders.ParentTableRelation.Add(relationFields);
RadGrid2.MasterTableView.DetailTables.Add(tableViewOrders);
protected
void RadGrid2_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
ConnectionStringSettings connectionString = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"];
_connection =
DbProviderFactories.GetFactory(connectionString.ProviderName).CreateConnection();
_connection.ConnectionString = connectionString.ConnectionString;
IDataReader reader;
using (IDbCommand command = _connection.CreateCommand())
{
command.CommandText =
"SpName";
command.CommandType =
CommandType.StoredProcedure;
_connection.Open();
reader = command.ExecuteReader();
}
((
RadGrid)source).DataSource = reader;
}
protected void RadGrid2_DataBound(object sender, EventArgs e)
{
if (_connection.State == ConnectionState.Open)
{
_connection.Close();
}
}
thanks in advance
Cristian.-