此事件中的代碼正好在另外兩個事件處理程序中重複。如何將重複的代碼放入方法中並從事件處理程序中調用該方法,因此我只需將其保存在一個地方?我不知道如何將事件參數傳遞給調用方法。摘要出重複代碼
protected void gvDocAssoc_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((Convert.ToString(DataBinder.Eval(e.Row.DataItem, "DETAIL_TYPE_DESC")) == "Transcript") &&
(Convert.ToString(DataBinder.Eval(e.Row.DataItem, "INSTITUTION_CODE")) == ""))
{
e.Row.BackColor = System.Drawing.Color.Red;
}
if ((Convert.ToString(DataBinder.Eval(e.Row.DataItem, "DETAIL_TYPE_DESC")) == "Certified Diploma") &&
(Convert.ToString(DataBinder.Eval(e.Row.DataItem, "INSTITUTION_CODE")) == ""))
{
e.Row.BackColor = System.Drawing.Color.Red;
}
if ((Convert.ToString(DataBinder.Eval(e.Row.DataItem, "DOC_TYPE_DESC")) == "Post Graduate conditions") &&
(Convert.ToString(DataBinder.Eval(e.Row.DataItem, "INSTITUTION_CODE")) == ""))
{
e.Row.BackColor = System.Drawing.Color.Red;
}
}
}
什麼問題將e作爲參數傳遞給第四功能? – 2010-03-31 16:15:55
到一個功能 – vittore 2010-03-31 16:30:09