I would like to create the function and pass the values to reduce the duplicate codes in my coding.
It will be called like this in GridView ItemDataBound event
DataRowView drv = e.Row.DataItem as DataRowView;
MyFunc(drv["HasDonePart1"]);
MyFunc(drv["HasDonePart2"]);
MyFunc(drv["HasDonePart3"]);
etc...
The function will be like the following
private void MyFunc ((ClassName) item)
{
if (item == DBNULL.value)
{
//do something
}
else
{
string myValue = item.ToString();
//do other things
}
}
But I don't know what should I put in my method to accept the object.
Change
MyFunc
to acceptobject
, instead: