0

i want to get the index value from selected rows of data grid..
how do i get it? can anyone explain...

2
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by hollystyles
0

In the aspx page DataGrid markup :

<asp:DataGrid id="DataGrid1" OnItemCommand="DataGrid1_ItemCommand" ...etc.

in the aspx.cs

protected void DataGrid1_ItemCommand(object sender, DataGridCommandEventArgs e)
{
    int index = e.Item.ItemIndex;
}
0

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.

#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);
			this.DataGrid1.ItemCommand += new DataGridCommandEventHandler(DataGrid1_ItemCommand);
			
		}
		#endregion
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.