DataGrid without data

L

Lee

Hello all,

Could any provide a link to an example of using a grid without a
datasource? I would like to manually populate the grid as well as
format it.

Thank you,

--
Warm Regards,
Lee

"Upon further investigation it appears that your software is missing
just one thing. It definitely needs more cow bell..."
 
M

Michael Nemtsev

Hello lee,

You can use custom class that returns ICollection interface. See codesnippet
below

public ICollection GroupsDataSource()
{
groupsDataTable = new DataTable("Rule Groups");

groupsDataTable.Columns.Add("GroupID");
groupsDataTable.Columns.Add("GroupName");
groupsDataTable.Columns.Add("AssignedRules");

Random rnd = new Random();
for (int i = 0; i < 5; i++)
{
newRow[0] = i.ToString();
newRow[1] = "Group" + i;
newRow[2] = "Rules" + i;

groupsDataTable.LoadDataRow(newRow, true);
}

return new DataView(groupsDataTable);
}

and then bind it to your DataGrid like

DataGrid1.DataSource = setsDataTable;
DataGrid1.DataBind();

l> Hello all,
l> Could any provide a link to an example of using a grid without a
l> datasource? I would like to manually populate the grid as well as
l> format it.
l>
l> Thank you,
l>
l> "Upon further investigation it appears that your software is missing
l> just one thing. It definitely needs more cow bell..."
l>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top