protected void ItemCommand(object sender, DataGridCommandEventArgs e) { // *** Button command Names contain Sku value if set if (e.CommandName != null && e.CommandName != "" && e.CommandName != "Page") { // *** If we clicked on one of the items to buy - redirect to the item page string sku = e.CommandName; string qty = ((TextBox) e.Item.FindControl("qty")).Text; if (sku != null && sku!="") { Server.Transfer("Item.aspx?sku=" + sku.Trim() + "&qty=" + qty + "&Action=Add"); //Response.Redirect("Item.aspx?sku=" + sku.Trim() + "&qty=" + qty + "&Action=Add"); } } }Note that you have to make sure you filter this correctly - especially filtering out Paging commands if your data grid has paging enabled.
> Private Sub GridPurposes_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GridPurposes.SelectedIndexChanged > Debug.WriteLine("grid clicked") > Dim dgcollection As DataGridItemCollection > Dim dgItem As DataGridItem = sender.Items(sender.SelectedIndex) > > End Sub > > > > >I Just found the code below that indicates that the .cells.text will return the value. >but this appeared blank "" to me in the watch window when I looked at it in debug window. > >I am at home now so will try this again tomorrow, >Any idea why they duplicated it when populating label1.text? > > Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChanged > Label1.Text = "You Selected " & DataGrid1.SelectedItem.Cells(1).Text & " " & DataGrid1.SelectedItem.Cells(1).Text > Label2.Text = "Selected Row Index is " & DataGrid1.SelectedIndex > End Sub > > > >