I am trying to dynamically create a div within the tab_content which is also a div.. then I am trying to check if the current row + "_tab_content" is equal to any ID within the tab_content, if so then do something.
For example the row["stars"].ToString() will print out "1" which makes it "1_tab_content"
int i = 1;
tab_content.Controls.Add(new LiteralControl("<div class='tab-pane' id='" + i.ToString() + "_tab_content' </div>"));
foreach(DataRow row in gymsByStars.Rows)
{
if(row["stars"].ToString() + "_tab_content" == tab_content.FindControl(row["stars"].ToString() + "_tab_content").ID.ToString())
{
// Do Something
}
}
However for some reason I recieve this error on the IF statement line System.NullReferenceException: Object reference not set to an instance of an object.
I honestly don't understand why though because the control has been dynamically created?
Does anyone understand what I am doing wrong?