Click here to Skip to main content
15,993,495 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi There,
I am working a small project and using devexpress tool.I am not getting correct code to get the value of a column in my code.Please,help me

Error here: string cid = row.EvalDataItem("HouseImageID").ToString();

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BuckshawObjects.Global;
using BuckshawObjects.Objects;
using DevExpress.Web.ASPxEditors;
using System.IO;
using DevExpress.Web.ASPxDataView;
using System.Collections;
using DevExpress.Web.ASPxGridView;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using DevExpress.XtraRichEdit.API.Native;
using System.Drawing;


namespace Buckshaw.Backend
{
    public partial class WebForm5 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        public void chkStatus_OnCheckedChanged(object sender, EventArgs e)
        {
            string constr = ConfigurationManager.ConnectionStrings["BuckshawHomesConnectionString"].ConnectionString;

            ASPxCheckBox chkStatus = (ASPxCheckBox)sender;
            //ASPxDataView row = (ASPxDataView)chkStatus.NamingContainer;
            DataViewItemTemplateContainer row=(DataViewItemTemplateContainer)chkStatus.NamingContainer;
            //string cid = row.Controls[0].ToString();
            //string cod =(row.ItemIndex+1).ToString();
            //string cod = row.ItemIndex.ToString();
            //string cod = dataView.FindControl("HouseImageID").ToString();
     
            //string cid = dataView.Controls[0].ToString();
            //string cod = dataView.Items[0].DataItem.ToString();
            string cid = row.EvalDataItem("HouseImageID").ToString();
            //string cid = "True";
            bool status = chkStatus.Checked;
           
            
            string query = "UPDATE [tblHouseImage] SET Active = @Approved WHERE HouseImageID = @HouseImageID";
            //WHERE HouseImageID = @HouseImageID"
            SqlConnection con = new SqlConnection(constr);
            SqlCommand com = new SqlCommand(query, con);
            com.Parameters.AddWithValue("@Approved", status);
            com.Parameters.AddWithValue("@HouseImageID", cid);
            con.Open();
            com.ExecuteNonQuery();
            con.Close();
           dataView.DataBind();

           
       
        }
    }
}
Posted
Updated 14-Mar-14 19:53pm
v2

1 solution

If you look at the documentation: https://help.devexpress.com/#AspNet/DevExpressWebASPxClassesItemTemplateContainerBase_EvalDataItemtopic[^] you will see that the parameter to EvalDataItme is an Expression - so the chances are that it wants somethign a little more like
HouseImageId=666
Than
HouseImageId
as a parameter...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900