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
|