Datagrid error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ashwani

    Datagrid error

    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_itemdatabo und1" width="100%" headerCSS="tblH eader"
    bodyCSS="tblBod y" autogeneratecol umns="False" GridLines="Hori zontal"
    BorderColor="#E 0E0E0" BackColor="Whit e" bodyHeight="400 " AllowSorting="T rue"
    AllowPaging="Tr ue" AllowCustomPagi ng="True">
    <Columns>
    <asp:TemplateCo lumn HeaderText="Ent ity">
    <ItemTemplate >
    <asp:label ID="name" text='<%#DataBi nder.eval(Conta iner.DataItem," Name")%>'
    Runat="server" />
    </ItemTemplate>
    </asp:TemplateCol umn>
    <asp:TemplateCo lumn HeaderText="Dis play">
    <ItemTemplate >
    <asp:CheckBox ID = "chkdisplay " runat="server" Checked=
    '<%#cbool(DataB inder.eval(Cont ainer.DataItem, "display")) %>' OnCheckedChange d
    = "ChangeSelectio n">
    </asp:CheckBox>
    </ItemTemplate>
    </asp:TemplateCol umn>
    </Columns>
    </asp:datagrid>

    C# Code:

    private void Page_Load(objec t sender, System.EventArg s e)
    {
    // Put user code to initialize the page here
    Bindgrid();
    }

    private void Bindgrid()
    {
    string connstring = ConfigurationSe ttings.AppSetti ngs["userprefconnst ring"];
    SqlConnection SQLConn = new SqlConnection(c onnstring);
    SQLConn.Open();
    SqlDataReader DR;
    SqlCommand Cmmd;
    String test = "9840da5f-1ede-da11-bd26-001125ac3fe6";
    string strquery="Selec t Name,Display, Rollup from tbl_UserPrefere nces where
    UserId='" + test +"' order by Name";
    Cmmd = new SqlCommand(strq uery, SQLConn);
    Cmmd.CommandTyp e = CommandType.Tex t;
    DR = Cmmd.ExecuteRea der();
    if (DR.HasRows)
    {
    dgSettings.Data Source = DR;
    dgSettings.Data Bind();
    }
    else
    {
    lblerrormsg.Tex t = "0 Records Retrieved.";
    }
    DR.Close();
    SQLConn.Close() ;
    }

    Thanks,
    Ashwani
  • Ignacio Machin \( .NET/ C# MVP \)

    #2
    Re: Datagrid error

    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" <Ashwani@discus sions.microsoft .com> wrote in message
    news:16567EA1-6310-49C6-BDFB-51558CEB8871@mi crosoft.com...[color=blue]
    > 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_itemdatabo und1" width="100%" headerCSS="tblH eader"
    > bodyCSS="tblBod y" autogeneratecol umns="False" GridLines="Hori zontal"
    > BorderColor="#E 0E0E0" BackColor="Whit e" bodyHeight="400 "
    > AllowSorting="T rue"
    > AllowPaging="Tr ue" AllowCustomPagi ng="True">
    > <Columns>
    > <asp:TemplateCo lumn HeaderText="Ent ity">
    > <ItemTemplate >
    > <asp:label ID="name"
    > text='<%#DataBi nder.eval(Conta iner.DataItem," Name")%>'
    > Runat="server" />
    > </ItemTemplate>
    > </asp:TemplateCol umn>
    > <asp:TemplateCo lumn HeaderText="Dis play">
    > <ItemTemplate >
    > <asp:CheckBox ID = "chkdisplay " runat="server" Checked=
    > '<%#cbool(DataB inder.eval(Cont ainer.DataItem, "display")) %>'
    > OnCheckedChange d
    > = "ChangeSelectio n">
    > </asp:CheckBox>
    > </ItemTemplate>
    > </asp:TemplateCol umn>
    > </Columns>
    > </asp:datagrid>
    >
    > C# Code:
    >
    > private void Page_Load(objec t sender, System.EventArg s e)
    > {
    > // Put user code to initialize the page here
    > Bindgrid();
    > }
    >
    > private void Bindgrid()
    > {
    > string connstring =
    > ConfigurationSe ttings.AppSetti ngs["userprefconnst ring"];
    > SqlConnection SQLConn = new SqlConnection(c onnstring);
    > SQLConn.Open();
    > SqlDataReader DR;
    > SqlCommand Cmmd;
    > String test = "9840da5f-1ede-da11-bd26-001125ac3fe6";
    > string strquery="Selec t Name,Display, Rollup from tbl_UserPrefere nces
    > where
    > UserId='" + test +"' order by Name";
    > Cmmd = new SqlCommand(strq uery, SQLConn);
    > Cmmd.CommandTyp e = CommandType.Tex t;
    > DR = Cmmd.ExecuteRea der();
    > if (DR.HasRows)
    > {
    > dgSettings.Data Source = DR;
    > dgSettings.Data Bind();
    > }
    > else
    > {
    > lblerrormsg.Tex t = "0 Records Retrieved.";
    > }
    > DR.Close();
    > SQLConn.Close() ;
    > }
    >
    > Thanks,
    > Ashwani[/color]


    Comment

    Working...