Hi all,
I have a CheckBox in a datagrid called DataFinAdjust. The Autopostback properties of the checkbox is set to true. At each post back i want to be able to do an update using other columns of the datagrid as unique identifiers. The challenge i have is that the ItemCommand event is not fired when the checkbox is either checked or unchecked. And figured out that if i used the checkedchanged event of the checkbox i'll have difficulty to get the row index of the datagrid at which the checkbox was checked or unchecked.
My code is as follow sombody please help.

protected void DataFinAdjust_ItemCommand(object source, DataGridCommandEventArgs e)
	   {
	   	var FieldID =  e.Item.Cells[13].Text;
	   	var Account = e.Item.Cells[14].Text;
	   	var cotflag = (CheckBox) e.Item.Cells[7].FindControl("chkcotflag");

	   	var fincost = new FinancialCostAdjustment(appConfiguration.ConnectionString)

					{
					    AcctCode = Account,
					    cotflag = cotflag.Checked,
					    ID = Convert.ToInt32(FieldID)
					};
	   	  fincost.UpdateCOTFLAG();

	   }

Do you have a column set as a datakey for the gridview? You usually need one for what you're trying to do.

No. I'm not using datagridview but datagrid.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.