How can I make my datacolumn contains an array instead of a single value??

  • Thread starter Thread starter ALI-R
  • Start date Start date
A

ALI-R

Is it a possibel to assign an array to a DataColumn then bind it to a Combo
box??
Is the follwoing code right?


public static DataSet InsertParamsToDS(ReportParameter[] arrParams)
{

DataSet RepDS=new DataSet();
DataTable objDataTable=new DataTable("ReportParams");
RepDS.Tables.Add(objDataTable);
objDataTable.Columns.Add("Name",typeof(string));
objDataTable.Columns.Add("ValidValues",typeof(ValidValue[]));

foreach(ReportParameter repParam in arrParams)
{
DataRow objDR=objDataTable.NewRow();
objDR ["Name"]=repParam.Name;

/**** I want in my Datagrid instead textbox for ValidValues a
combobox holds the values of "repParam.ValidValues"*//////
objDR ["ValidValues"]=repParam.ValidValues;

objDataTable.Rows.Add(objDR);
}

return RepDS;

}
 
ALI-R,

The only SQL data type that would support an array is a binary type,
which will return to you an array of bytes. Other than that, no you can not
do this, as array types are not supported by the DataSet (at least, as
column types, nor are they supported by most databases).

If anything, create another table that you can create a relation to
where every row would be an entry in your array (where the key in the parent
table indicates which rows from the child table to use).

Hope this helps.
 
Thanks for your help,,

my problem is that for each row there is a differnet child table because
each row has its own array ,how can I create dynamic childTables and bind
them to the parent table??

I am so dissappointed!:-)
Thanks
Nicholas Paldino said:
ALI-R,

The only SQL data type that would support an array is a binary type,
which will return to you an array of bytes. Other than that, no you can not
do this, as array types are not supported by the DataSet (at least, as
column types, nor are they supported by most databases).

If anything, create another table that you can create a relation to
where every row would be an entry in your array (where the key in the parent
table indicates which rows from the child table to use).

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

ALI-R said:
Is it a possibel to assign an array to a DataColumn then bind it to a
Combo
box??
Is the follwoing code right?


public static DataSet InsertParamsToDS(ReportParameter[] arrParams)
{

DataSet RepDS=new DataSet();
DataTable objDataTable=new DataTable("ReportParams");
RepDS.Tables.Add(objDataTable);
objDataTable.Columns.Add("Name",typeof(string));
objDataTable.Columns.Add("ValidValues",typeof(ValidValue[]));

foreach(ReportParameter repParam in arrParams)
{
DataRow objDR=objDataTable.NewRow();
objDR ["Name"]=repParam.Name;

/**** I want in my Datagrid instead textbox for ValidValues a
combobox holds the values of "repParam.ValidValues"*//////
objDR ["ValidValues"]=repParam.ValidValues;

objDataTable.Rows.Add(objDR);
}

return RepDS;

}
 
ALI-R,

You can just create a new instance of the data table and add it through
the Add method on the DataTablesCollection returned from the Tables
property.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

ALI-R said:
Thanks for your help,,

my problem is that for each row there is a differnet child table because
each row has its own array ,how can I create dynamic childTables and bind
them to the parent table??

I am so dissappointed!:-)
Thanks
in
message news:%[email protected]...
ALI-R,

The only SQL data type that would support an array is a binary type,
which will return to you an array of bytes. Other than that, no you can not
do this, as array types are not supported by the DataSet (at least, as
column types, nor are they supported by most databases).

If anything, create another table that you can create a relation to
where every row would be an entry in your array (where the key in the parent
table indicates which rows from the child table to use).

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

ALI-R said:
Is it a possibel to assign an array to a DataColumn then bind it to a
Combo
box??
Is the follwoing code right?


public static DataSet InsertParamsToDS(ReportParameter[] arrParams)
{

DataSet RepDS=new DataSet();
DataTable objDataTable=new DataTable("ReportParams");
RepDS.Tables.Add(objDataTable);
objDataTable.Columns.Add("Name",typeof(string));
objDataTable.Columns.Add("ValidValues",typeof(ValidValue[]));

foreach(ReportParameter repParam in arrParams)
{
DataRow objDR=objDataTable.NewRow();
objDR ["Name"]=repParam.Name;

/**** I want in my Datagrid instead textbox for ValidValues a
combobox holds the values of "repParam.ValidValues"*//////
objDR ["ValidValues"]=repParam.ValidValues;

objDataTable.Rows.Add(objDR);
}

return RepDS;

}
 
Let me explain my problem,,
I am trying to connect to a report on the reporting service and extracting
all its parameters and their values(which are based on the query) and let
the user edit those paramters value and submit the report,my ONLY problem is
that how to show these params ,I am using a datagrid ,but I am stuck because
each row which represents a paramater has differnt set of values!!!! and I
can't show them.

Do you have any suggestions how to do that??

I aapriciate your help.
ALI
Nicholas Paldino said:
ALI-R,

You can just create a new instance of the data table and add it through
the Add method on the DataTablesCollection returned from the Tables
property.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

ALI-R said:
Thanks for your help,,

my problem is that for each row there is a differnet child table because
each row has its own array ,how can I create dynamic childTables and bind
them to the parent table??

I am so dissappointed!:-)
Thanks
in
message news:%[email protected]...
ALI-R,

The only SQL data type that would support an array is a binary type,
which will return to you an array of bytes. Other than that, no you
can
not
do this, as array types are not supported by the DataSet (at least, as
column types, nor are they supported by most databases).

If anything, create another table that you can create a relation to
where every row would be an entry in your array (where the key in the parent
table indicates which rows from the child table to use).

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Is it a possibel to assign an array to a DataColumn then bind it to a
Combo
box??
Is the follwoing code right?


public static DataSet InsertParamsToDS(ReportParameter[] arrParams)
{

DataSet RepDS=new DataSet();
DataTable objDataTable=new DataTable("ReportParams");
RepDS.Tables.Add(objDataTable);
objDataTable.Columns.Add("Name",typeof(string));
objDataTable.Columns.Add("ValidValues",typeof(ValidValue[]));

foreach(ReportParameter repParam in arrParams)
{
DataRow objDR=objDataTable.NewRow();
objDR ["Name"]=repParam.Name;

/**** I want in my Datagrid instead textbox for ValidValues a
combobox holds the values of "repParam.ValidValues"*//////
objDR ["ValidValues"]=repParam.ValidValues;

objDataTable.Rows.Add(objDR);
}

return RepDS;

}
 
Back
Top