Problem getting the row index of a datagrid

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2006
Posts: 22
Reputation: ema005 is an unknown quantity at this point 
Solved Threads: 4
ema005 ema005 is offline Offline
Newbie Poster

Problem getting the row index of a datagrid

 
0
  #1
Aug 13th, 2009
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.
  1. protected void DataFinAdjust_ItemCommand(object source, DataGridCommandEventArgs e)
  2. {
  3. var FieldID = e.Item.Cells[13].Text;
  4. var Account = e.Item.Cells[14].Text;
  5. var cotflag = (CheckBox) e.Item.Cells[7].FindControl("chkcotflag");
  6.  
  7. var fincost = new FinancialCostAdjustment(appConfiguration.ConnectionString)
  8.  
  9. {
  10. AcctCode = Account,
  11. cotflag = cotflag.Checked,
  12. ID = Convert.ToInt32(FieldID)
  13. };
  14. fincost.UpdateCOTFLAG();
  15.  
  16. }
Emmanuel Balogun
Senior .Net Developer
Precise Financial Systems
Lagos-Nigeria.
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: Problem getting the row index of a datagrid

 
0
  #2
Aug 13th, 2009
Do you have a column set as a datakey for the gridview? You usually need one for what you're trying to do.
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 22
Reputation: ema005 is an unknown quantity at this point 
Solved Threads: 4
ema005 ema005 is offline Offline
Newbie Poster

Re: Problem getting the row index of a datagrid

 
0
  #3
Aug 18th, 2009
No. I'm not using datagridview but datagrid.
Emmanuel Balogun
Senior .Net Developer
Precise Financial Systems
Lagos-Nigeria.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC