dannystommen
August 28th, 2009, 04:33 AM
In my gridview rowdatabound event I have the following code
if (e.Row.RowType == DataControlRowType.DataRow) {
line_item item = e.Row.DataItem as line_item;
if (!item.active)
(e.Row.FindControl("linkName") as HyperLink).CssClass = "inactive";
(e.Row.FindControl("linkName") as HyperLink).NavigateUrl = "someUrl.aspx?id=" +
item.id;
//do some more stuff with linkName
}
To improve its readablity in changed it to
if (e.Row.RowType == DataControlRowType.DataRow) {
line_item item = e.Row.DataItem as line_item;
HyperLink linkName = (e.Row.FindControl("linkName") as HyperLink);
if (!item.active)
linkName.CssClass = "inactive";
linkName.NavigateUrl = "someUrl.aspx?id=" + item.id;
//do some more stuff with linkName
// linkName.Dispose(); ????
}
My question, should the created Hyperlink 'linkName' be disposed or not?
if (e.Row.RowType == DataControlRowType.DataRow) {
line_item item = e.Row.DataItem as line_item;
if (!item.active)
(e.Row.FindControl("linkName") as HyperLink).CssClass = "inactive";
(e.Row.FindControl("linkName") as HyperLink).NavigateUrl = "someUrl.aspx?id=" +
item.id;
//do some more stuff with linkName
}
To improve its readablity in changed it to
if (e.Row.RowType == DataControlRowType.DataRow) {
line_item item = e.Row.DataItem as line_item;
HyperLink linkName = (e.Row.FindControl("linkName") as HyperLink);
if (!item.active)
linkName.CssClass = "inactive";
linkName.NavigateUrl = "someUrl.aspx?id=" + item.id;
//do some more stuff with linkName
// linkName.Dispose(); ????
}
My question, should the created Hyperlink 'linkName' be disposed or not?