C
CGuy
Hi,
I have an ASPX page which has a datagrid and this datagrid is bound to a
Custom Collection.
sample code
this.DataGrid1.DataSource = UserManager.Users;
this.DataGrid1.DataBind();
Everything works fine and when the page is loaded, the datagrid displays
the list of users present in the Usermanager.Users object.
Now, I want to do a conditional binding - for example, I want the
datagrid to have only those users who have certain privileges. To be more
specific, this is what I want to do
foreach(User user in UserManager.Users)
{
if(user.Privileges.Contains(certainPrivilege) ||
user.Privileges.Contains(anotherCertainPrivilege)
{
//Add the row to the grid
}
else
{
//Do not add this row to the grid
}
}
How do I accomplish this - please note that I don't want to the change the
datasource of the grid to reflect this - the data source should be the
entire list of Users and not a filtered list based on priviliges.
Please help me with this - what I am looking for is a solution which will
allow me to use the ItemDataBound or DataBinding events to do this.
Also, I do not want to hide the rows (visible = false). This spoils the
paging routines in the page.
CGuy
I have an ASPX page which has a datagrid and this datagrid is bound to a
Custom Collection.
sample code
this.DataGrid1.DataSource = UserManager.Users;
this.DataGrid1.DataBind();
Everything works fine and when the page is loaded, the datagrid displays
the list of users present in the Usermanager.Users object.
Now, I want to do a conditional binding - for example, I want the
datagrid to have only those users who have certain privileges. To be more
specific, this is what I want to do
foreach(User user in UserManager.Users)
{
if(user.Privileges.Contains(certainPrivilege) ||
user.Privileges.Contains(anotherCertainPrivilege)
{
//Add the row to the grid
}
else
{
//Do not add this row to the grid
}
}
How do I accomplish this - please note that I don't want to the change the
datasource of the grid to reflect this - the data source should be the
entire list of Users and not a filtered list based on priviliges.
Please help me with this - what I am looking for is a solution which will
allow me to use the ItemDataBound or DataBinding events to do this.
Also, I do not want to hide the rows (visible = false). This spoils the
paging routines in the page.
CGuy