View Single Post
  #2 (permalink)  
Old August 23rd, 2004, 09:47 AM
mehdi62b mehdi62b is offline
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

its not a beginer's question.!
I think you should have a checkbox somewhere like ItemTemplate and also you
fill your grid with your datasource,well
for getting what is bound to your filed you should work with
yourDataGridItem.DataItem.
and also for changing the backcolor,you can work with yourDataGridItem.CssClass
and also you should have a <STYLE></STYLE> tag in your aspx file and set the CssClass
with one of the styles declared in your <STYLE> tag.
but where you can work with them?surely somewhere like DataGrid1_ItemDataBound
have a look at this example...
Code:
private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||
    e.Item.ItemType == ListItemType.AlternatingItem ||
    e.Item.ItemType == ListItemType.SelectedItem ||
    e.Item.ItemType == ListItemType.EditItem)
        {    
            if(((DataRowView)e.Item.DataItem).Row.ItemArray[0].ToString()=="aSpecialValue")
            {
                ((CheckBox)e.Item.Cells[0].FindControl("yourUniqueCheckBoxID")).Checked=true;
                e.Item.CssClass="YourNewCssDecalredInStyleTag";
            }
        }
}
this example marks every item that aSpecialValue has been bound to it also change it's
CSS changes according to YourNewCssDecalredInStyleTag.
HtH.

--------------------------------------------
Mehdi.:)
Reply With Quote