Hi, I want to know how to add a dinamyc <%# Eval("") %> but in C#.
I have a DataGrid with SQL Connection and I have case that I can choose what Table can be show in GridView. If i add the Items in HTML, the items are static, but if I do it in C#, i can use 1 GridView and change the Items, but i don't know how to do a Dynamic Eval.
I do this when i have the items in C#:
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlDataAdapter sda = new SqlDataAdapter(" select No_curse, Room, Time from AgS")
{
gvSesion.DataSource = null;
gvSesion.DataBind();
using (DataTable dt = new DataTable())
{
dt.Columns.Add("No_curse");
dt.Columns.Add("Room");
dt.Columns.Add("Time");
sda.Fill(dt);
gvCursos.DataSource = dt;
gvCursos.DataBind();
}}}
But I want add the Eval propietie like this:
<td><asp:Button ID="cmdView" runat="server" Text="+" CommandName="Select" /></td>
<td><asp:Label ID="No_curse" runat="server" Text='<%# Eval("No_curse") %>'></asp:Label></td>
<td><asp:Label ID="Room" runat="server" Text='<%# Eval("Room") %>'></asp:Label></td>
<td><asp:Label ID="Time" runat="server" Text='<%# Eval("Time") %>'></asp:Label></td>