Re: Forming server tag error
When doing inline code within a control, it needs to be wrapped in single quotes, not double, and the entire expression should be in the server tags, not part of it:
Code:
<div id='<%# "div" + Eval("SymptomUniqueId") %>' runat="server" style="display:none;position:relative;left:15px;OVERFLOW: auto;WIDTH:97%"></div>
Re: Forming server tag error
Thanks for the reply. I tried this and got the following error:
Parser Error Message: The ID property of a control can only be set using the ID attribute in the tag and a simple value. Example: <asp:Button runat="server" id="Button1" />
Re: Forming server tag error
I guess that means you can't have the ID as a server-generated property, then... oh well. That's what HTML injection is for :D
Be warned that while this is an extraordinarily dynamic solution that provides you with incredible power, it's also very precise, and needs to be done right, or the affected pages will render in impressively wrong ways. I've done it a few times, so stick to the basics and you should be fine.
Replace that div with an <asp:Literal> control, give it a static ID and runat="server". Then create the RowDataBound event if it isn't already. Everything from here happens in the code-behind (forgive my C#... untested, but based on code I've written a dozen times):
Code:
protected void gdv1_RowDataBound(object sender, GridViewRowEventArgs e) {
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView drv = (DataRowView)e.Row.DataItem;
Literal myLit = (Literal)e.Row.FindControl("myLiteral");
myLit.Text = "<div id=\"div" + drv["SymptomUniqueId"].ToString() + "\" runat=\"server\" style=\"display:none;position:relative;left:15px;OVERFLOW: auto;WIDTH:97%\"></div>";
}
}
Essentially, this is determining the entire HTML output of the div before actually creating it, and Literals render exactly what's in their Text property and nothing else, so your resulting markup will look the same.