我的DataGridView
id FN LastN City Deg Skillset Gender
10 ma Alex Trichy BE .net,html,sql Male
11 giri mani Madu BE .net, java Male
当我点击id 10时,我希望检查我的checkedlistbox项目(.net,html,sql)。 c#plz ..
答案 0 :(得分:1)
你可以通过使用javascript在datagrid视图的每一行上放置一个click事件来实现它
dataGridView1.RowDataBound += new GridViewRowEventHandler(dataGridView1_RowDataBound);
void dataGridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.DataItem != null)
{
var r = Convert.ToInt32(ViewData["RequesterCode"]);
if (e.Row.DataItem is AC.CCBS.ServiceFactory.AndcWorkFlow.RequestView)
{
var s = e.Row.DataItem as AC.CCBS.ServiceFactory.AndcWorkFlow.RequestView;
var r1 = s.RequestCode;
e.Row.Attributes.Add("onclick","DoSome(this);");
}
}
}
<script DoSome>
DoSome=function(sender){
//do something here
}