如何使用devexpress Web表单工具在字符串中分配单元格行 [英] How to assign the cell row in a string using devexpress web form tools

查看:100
本文介绍了如何使用devexpress Web表单工具在字符串中分配单元格行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI ALL,



我使用devexpress asp.net工具和代码。但我发现难以将行单元格分配给字符串,如下所示:

  string  cid = row.Cells [ 1 ].Text;  //  此行中的错误 



请,帮我看看如何用devexpress编写上面的代码...

  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 ]。文字; // 此行中的错误

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();
}
}

解决方案

  var  chk =(CheckBox)发件人; 
var row =(GridViewRow)chk.NamingContainer;
var index = row.RowIndex;
var str = gridview1.Rows [index] .Cells [ 1 ]。文字;


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:

string cid = row.Cells[1].Text; // Error in this line


Please, help me how to write above code in devexpress...

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();         
    }    
}

解决方案

var chk = (CheckBox)sender;
var row = (GridViewRow)chk.NamingContainer;
var index = row.RowIndex;
var str = gridview1.Rows[index].Cells[1].Text;


这篇关于如何使用devexpress Web表单工具在字符串中分配单元格行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆