Radgrid 行里控件的事件,例如checkbox事件

protected void chb_CheckedChanged(object sender, EventArgs e)

    {

        // 获取控件所在 griddataitem (我理解是行)的 item (行)标示 , 一个控件的 parent cell cell parent griddataitem

GridDataItem item = (GridDataItem ) ((CheckBox ) sender).Parent.Parent;

       // 将触发的事件转换成相应的控件

CheckBox chb = (CheckBox ) sender;

        bool cks = chb.Checked;

 

// 获取该 item 上的 taskid 的值

string taskId = item.OwnerTableView.DataKeyValues[item.ItemIndex]["taskId" ].ToString();

        string teamId = RadComboBox1.SelectedValue.ToString();

 

        if (chb.Checked)

        {

            string insertsql = "insert into TaskTeam(taskId,teamId) values('" + taskId + "','" + teamId + "')" ;

            DbConnector .runSql(insertsql);

        }

        else

        {

            string deletesql = "delete from TaskTeam where teamId='" + teamId + "' and taskId= " + taskId;

            DbConnector .runSql(deletesql);

        }

    }

你可能感兴趣的:(.net,telerik)