Click here to Skip to main content
15,903,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HI ALL,

Iam using devexpress asp.net tool and code.But I have found on e difficulty to assign the row cell to a string as shown below:
C#
string cid = row.Cells[1].Text; // Error in this line

Please, help me how to write above code in devexpress...
C#
public void chkStatus_OnCheckedChanged(object sender, EventArgs e)
{
     public void chkStatus_OnCheckedChanged(object sender, EventArgs e)
    {     
        ASPxCheckBox chkStatus = (ASPxCheckBox)sender;
        GridViewDataRowTemplateContainer row = chkStatus.NamingContainer as GridViewDataRowTemplateContainer;
        string cid = row.Cells[1].Text; // Error in this line
      
        bool status = chkStatus.Checked;
    
        string constr = ConfigurationManager.ConnectionStrings["BuckshawHomesConnectionString"].ConnectionString;
        string query = "UPDATE [tblHouseImage] SET Active = @Approved 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();
        grid.DataBind();         
    }    
}
Posted
v2

1 solution

C#
var chk = (CheckBox)sender;
var row = (GridViewRow)chk.NamingContainer;
var index = row.RowIndex;
var str = gridview1.Rows[index].Cells[1].Text;
 
Share this answer
 
v2
Comments
[no name] 11-Mar-14 9:12am    
No no, My code is working good in simple asp.net control.I want to implement this code in devexpress.
string cid = row.Cells[1].Text; This line has an error Because Iam unable to write this code in devexpress code because cells is not there in devexpress ,so its showing error.
Thanks,

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



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