943,708 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 2841
  • ASP.NET RSS
Aug 13th, 2009
0

Problem getting the row index of a datagrid

Expand Post »
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.
ASP.NET Syntax (Toggle Plain Text)
  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. }
Reputation Points: 10
Solved Threads: 4
Newbie Poster
ema005 is offline Offline
24 posts
since Jan 2006
Aug 13th, 2009
0

Re: Problem getting the row index of a datagrid

Do you have a column set as a datakey for the gridview? You usually need one for what you're trying to do.
Team Colleague
Reputation Points: 186
Solved Threads: 147
Cookie... That's it
alc6379 is offline Offline
2,519 posts
since Dec 2003
Aug 18th, 2009
0

Re: Problem getting the row index of a datagrid

No. I'm not using datagridview but datagrid.
Reputation Points: 10
Solved Threads: 4
Newbie Poster
ema005 is offline Offline
24 posts
since Jan 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Base clase
Next Thread in ASP.NET Forum Timeline: grid view with fixed header





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC