Datagrid error

G

Guest

Hi,

I am getting below error while using the ItemTemplate in datagrid. Please
help, this is very very urgent.

CS0117: 'System.Web.UI.DataBinder' does not contain a definition for 'eval'

Below is my code to populate datagrid.

HTML Code:

<asp:datagrid id="dgSettings" runat="server"
OnItemDataBound="DG_itemdatabound1" width="100%" headerCSS="tblHeader"
bodyCSS="tblBody" autogeneratecolumns="False" GridLines="Horizontal"
BorderColor="#E0E0E0" BackColor="White" bodyHeight="400" AllowSorting="True"
AllowPaging="True" AllowCustomPaging="True">
<Columns>
<asp:TemplateColumn HeaderText="Entity">
<ItemTemplate>
<asp:label ID="name" text='<%#DataBinder.eval(Container.DataItem,"Name")%>'
Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Display">
<ItemTemplate>
<asp:CheckBox ID = "chkdisplay" runat="server" Checked=
'<%#cbool(DataBinder.eval(Container.DataItem,"display"))%>' OnCheckedChanged
= "ChangeSelection">
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

C# Code:

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Bindgrid();
}

private void Bindgrid()
{
string connstring = ConfigurationSettings.AppSettings["userprefconnstring"];
SqlConnection SQLConn = new SqlConnection(connstring);
SQLConn.Open();
SqlDataReader DR;
SqlCommand Cmmd;
String test = "9840da5f-1ede-da11-bd26-001125ac3fe6";
string strquery="Select Name,Display, Rollup from tbl_UserPreferences where
UserId='" + test +"' order by Name";
Cmmd = new SqlCommand(strquery, SQLConn);
Cmmd.CommandType = CommandType.Text;
DR = Cmmd.ExecuteReader();
if (DR.HasRows)
{
dgSettings.DataSource = DR;
dgSettings.DataBind();
}
else
{
lblerrormsg.Text = "0 Records Retrieved.";
}
DR.Close();
SQLConn.Close();
}

Thanks,
Ashwani
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


Remember, C# is case sensitive, try Eval instead of eval
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top