Jean
|
| Posted: 07/08/2002, 5:58 PM |
|
Hi,
I looking for codes in C# how to reference to a field in a grid in the
Before Show Row event. I generated the grid (list page) using the wizard.
By looking at the code, I know there is a data repeater object.
Thanks
Jean
|
|
|
 |
Sanddy
|
| Posted: 07/08/2002, 10:47 PM |
|
Well the "Before Show Row" event for the DataGrid maps to the
OnItemDataBound event of the Repeater, which can be clearly seen if you
switch to code view...
Well inside this method .. you will have to first search for the Control ..
using the
e.Item.FindControl("controlName") etc .. see the MSDN .NET Reference
Documentation .. it has code on usage of the OnItemDataBound event of the
Repeater.
eg
//Check the ListItem type .. since headers and footers
//won't have these controls
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
//Get the control
System.Web.UI.WebControls.Literal
ImagesImageID=(System.Web.UI.WebControls.Literal)(e.Item.FindControl("Images
ImageID"));
}
But if you want to modify a field from the Grid, it will be more easy, if
you select the field in the Grid add the event to the "Before Show" of the
field ...
This will again map to the OnItemDataBound event, but in this case CCS will
also write all the necessary code to find the control from the Repeater....
CCS Fan,
Sanddy
|
|
|
 |
|