PC Review


Reply
Thread Tools Rate Thread

Datagrid error

 
 
=?Utf-8?B?QXNod2FuaQ==?=
Guest
Posts: n/a
 
      20th Jun 2006
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
 
Reply With Quote
 
 
 
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      20th Jun 2006
Hi,


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


--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



"Ashwani" <(E-Mail Removed)> wrote in message
news:16567EA1-6310-49C6-BDFB-(E-Mail Removed)...
> 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



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Datagrid Error Jeff Dillon Microsoft VB .NET 0 12th Apr 2006 09:10 PM
datagrid error rogo Microsoft ASP .NET 1 13th Jan 2006 09:13 PM
RE: help with dataGrid error =?Utf-8?B?UmFodWwgQSBNZWh0YQ==?= Microsoft Dot NET 0 28th Dec 2004 07:05 AM
Datagrid Error Michael Chong Microsoft ASP .NET 0 2nd Dec 2004 09:44 AM
Error with datagrid Tonya Microsoft Dot NET 1 19th Nov 2003 11:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:01 AM.