|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ASP.NET 2.0 equivalent for e.Item.ItemIndex ?Hello,
I'm raising an event in a datagrid when clicking on a deletecommand button. I want to get the selected value of the datagrid. In ASP.NET 1.1 I did this whit e.Item.ItemIndex In ASP.NET 2.0 I can't use this anymore because EventArgs e has only the properties/methods tostring, Equals, getHashcode and getType. Does somebody know a solution for this ? thx, Use the ItemCommand event:
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.itemcommand(VS.80).aspx Show quoteHide quote "RG" wrote: > Hello, > > I'm raising an event in a datagrid when clicking on a deletecommand button. > I want to get the selected value of the datagrid. > > In ASP.NET 1.1 I did this whit e.Item.ItemIndex > In ASP.NET 2.0 I can't use this anymore because EventArgs e has only the > properties/methods tostring, Equals, getHashcode and getType. > > Does somebody know a solution for this ? > > thx, > > > It should work just the way you're familiar with because
DataGridCommandEventArgs still has the Item property. Protected Sub dataGrid1_DeleteCommand(ByVal source As Object, ByVal e As DataGridCommandEventArgs) Handles dataGrid1.DeleteCommand lbl.Text = "Deleting row number " & e.Item.ItemIndex myDataView.Delete(e.Item.ItemIndex) dataGrid1.DataBind End Sub <CaffieneR***@gmail.com> schreef in bericht
news:1143493457.971066.198020@g10g2000cwb.googlegroups.com... Hi, this works but e.Item.ItemIndex returns the number of the row in the > It should work just the way you're familiar with because > DataGridCommandEventArgs still has the Item property. > > Protected Sub dataGrid1_DeleteCommand(ByVal source As Object, ByVal e > As DataGridCommandEventArgs) Handles dataGrid1.DeleteCommand > > lbl.Text = "Deleting row number " & e.Item.ItemIndex > myDataView.Delete(e.Item.ItemIndex) > dataGrid1.DataBind > > End Sub datagrid, but not the datakeyfield. How can i see this ? thx Are you asking how to get the primary key value for the row in
question? If you are then use the DataKeys collection property of your DataGrid. 'Within the DeleteCommand (or ItemCommand event handler and filtering for the delete command) datagrid1.DataKeys(e.Item.ItemIndex) <CaffieneR***@gmail.com> schreef in bericht
news:1143586019.764101.193840@t31g2000cwb.googlegroups.com... thats it yes!> Are you asking how to get the primary key value for the row in > question? If you are then use the DataKeys collection property of your > DataGrid. > > 'Within the DeleteCommand (or ItemCommand event handler and filtering > for the delete command) > datagrid1.DataKeys(e.Item.ItemIndex) Thanks for the solution
Adding controls to Pager row in GridView
Templated control not rendering Web User Controls Trouble with validator control ? Script not found using placeholders Is there a free .GIF software? Trouble with validator control ? script not found Display data in asp:Calendar servercontrols (webcontrols, htmlcontrols) or html elements? Gridview and colspan Scroll position in panel control |
|||||||||||||||||||||||