When dataList is bound to a row set, use <% # DataBinder. eval (Container. dataItem, "fldName") %>, "DataBinder. eval: "System. data. dataRow "does not contain the fldName attribute" error
Solution: Set <% # DataBinder. eval (Container. dataItem, "fldName") %> as <% # DataBinder. eval (Container. dataItem, "(fldName)") %>
() Can also be replaced.
------------------------------------
For example:
.....
DataSet ds = ...;
DataTable dt = ...;
DataRow [] dr = dt. Select ("...");
DbList. DataSource = dr;
DbList. DataBind ();
---------------------------------
<Asp: DataList id = "dbList" runat = "server" Width = "100%" RepeatDirection = "Horizontal" RepeatColumns = "2">
<ItemTemplate>
Company Name: <% # DataBinder. Eval (Container. DataItem, "[CompanyName]") %>
</ItemTemplate>
</Asp: DataList>
You can also write it as follows:
Company Name: <% # DataBinder. Eval (Container. DataItem, "(CompanyName)") %>
I am not sure why I want to write it like this. I am studying it...
If any boss knows, thank you for your support ^