944,061 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 2215
  • C# RSS
May 25th, 2007
0

data grid.... very urgent......

Expand Post »
i want to get the index value from selected rows of data grid..
how do i get it? can anyone explain...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gurusamy is offline Offline
9 posts
since May 2007
May 25th, 2007
0

Re: data grid.... very urgent......

int index = DataGrid1.SelectedIdex;
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005
May 25th, 2007
0

Re: data grid.... very urgent......

i got index value -1 for all rows..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gurusamy is offline Offline
9 posts
since May 2007
May 25th, 2007
0

Re: data grid.... very urgent......

In the aspx page DataGrid markup :

C# Syntax (Toggle Plain Text)
  1. <asp:DataGrid id="DataGrid1" OnItemCommand="DataGrid1_ItemCommand" ...etc.
in the aspx.cs
C# Syntax (Toggle Plain Text)
  1. protected void DataGrid1_ItemCommand(object sender, DataGridCommandEventArgs e)
  2. {
  3. int index = e.Item.ItemIndex;
  4. }
Last edited by WolfPack; May 25th, 2007 at 12:11 pm. Reason: Edited per user's request
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005
May 25th, 2007
0

Re: data grid.... very urgent......

Quote ...
gurusamy (in PM to me)
i tried that too..
Whether i have to set any property for data grid..
bcoz i didn't get any event for data grid like ItemsIndex..
Have you wired up the event handler ?, if you're not using the designer but handcoding you have to add the handler delegates in the Web Form Designer generated code region of the aspx.cs file (If you're using Framework 1.1) See near the bottom of this snippet in the InitializeComponent method.

C# Syntax (Toggle Plain Text)
  1. #region Web Form Designer generated code
  2. override protected void OnInit(EventArgs e)
  3. {
  4. //
  5. // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  6. //
  7. InitializeComponent();
  8. base.OnInit(e);
  9. }
  10.  
  11. /// <summary>
  12. /// Required method for Designer support - do not modify
  13. /// the contents of this method with the code editor.
  14. /// </summary>
  15. private void InitializeComponent()
  16. {
  17. this.Load += new System.EventHandler(this.Page_Load);
  18. this.DataGrid1.ItemCommand += new DataGridCommandEventHandler(DataGrid1_ItemCommand);
  19.  
  20. }
  21. #endregion
Last edited by hollystyles; May 25th, 2007 at 11:48 am.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005

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 C# Forum Timeline: Getting Available Groups
Next Thread in C# Forum Timeline: Namespaces





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


Follow us on Twitter


© 2011 DaniWeb® LLC