|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Adding "delete" functionality in DataGrid - without a ButtonColumnthe user to click a "delete" button in each row of the datagrid to delete records. I originally used a <asp:ButtonColumn> for this and gave it a CommandName attribute. This worked great. However, the client wants to have a popup when they click on the delete button. So now I'm thinking that I have to create a javaScript function and instead of using an <asp:ButtonColumn>, I'll have to use an <asp:TemplateColumn> with an embedded <asp:button> inside of the item template. In this button I'm imagining I'll be able to do an onclick javascript event handler, but I'm not sure how to do this. I'm unsure how to create this type of functionality. The important piece is being able to pass the data for the entire row, from which the delete button was clicked, to the javascript function. This was easily done with the button colum because the _ItemCommand event handler for the datagrid took the input: DataGridCommandEventArgs, which had the data for the entire row. Any thoughts? Your help is greatly appreciated. -- PK9 You can still keep the delete button but change deleting
function to collect data and save data to SessionState. Then popup delete page, Response.Write("<script>open ('delete.aspx')</script>"). In delete page, retrieve data from SessionState. HTH, Elton Wang >-----Original Message----- and I want to allow >I have a datagrid that brings back a number of records >the user to click a "delete" button in each row of the datagrid to delete >records. I originally used a <asp:ButtonColumn> for this and gave it a >CommandName attribute. This worked great. However, the client wants to have >a popup when they click on the delete button. function and instead > >So now I'm thinking that I have to create a javaScript >of using an <asp:ButtonColumn>, I'll have to use an <asp:TemplateColumn> with >an embedded <asp:button> inside of the item template. In this button I'm >imagining I'll be able to do an onclick javascript event handler, but I'm not >sure how to do this. The important piece > >I'm unsure how to create this type of functionality. >is being able to pass the data for the entire row, from which the delete >button was clicked, to the javascript function. This was easily done with >the button colum because the _ItemCommand event handler for the datagrid took >the input: DataGridCommandEventArgs, which had the data for the entire row. Show quoteHide quote > >Any thoughts? Your help is greatly appreciated. > >-- >PK9 >. > That was my last option if I couldn't figure out another way. I don't want
to deal with another aspx page and session variables. I found my answer on the following website. This shows examples to do it with a buttoncolumn and an itemtemplate column! Great reference!!! http://authors.aspalliance.com/aldotnet/examples/cd.aspx Show quoteHide quote "Elton Wang" wrote: > You can still keep the delete button but change deleting > function to collect data and save data to SessionState. > Then popup delete page, Response.Write("<script>open > ('delete.aspx')</script>"). In delete page, retrieve data > from SessionState. > > HTH, > > Elton Wang > > >-----Original Message----- > >I have a datagrid that brings back a number of records > and I want to allow > >the user to click a "delete" button in each row of the > datagrid to delete > >records. I originally used a <asp:ButtonColumn> for this > and gave it a > >CommandName attribute. This worked great. However, the > client wants to have > >a popup when they click on the delete button. > > > >So now I'm thinking that I have to create a javaScript > function and instead > >of using an <asp:ButtonColumn>, I'll have to use an > <asp:TemplateColumn> with > >an embedded <asp:button> inside of the item template. In > this button I'm > >imagining I'll be able to do an onclick javascript event > handler, but I'm not > >sure how to do this. > > > >I'm unsure how to create this type of functionality. > The important piece > >is being able to pass the data for the entire row, from > which the delete > >button was clicked, to the javascript function. This was > easily done with > >the button colum because the _ItemCommand event handler > for the datagrid took > >the input: DataGridCommandEventArgs, which had the data > for the entire row. > > > >Any thoughts? Your help is greatly appreciated. > > > >-- > >PK9 > >. > > > So actually, you want a deleting confirmation.
Elton Wang >-----Original Message----- way. I don't want >That was my last option if I couldn't figure out another >to deal with another aspx page and session variables. examples to do it >I found my answer on the following website. This shows Show quoteHide quote >with a buttoncolumn and an itemtemplate column! Great reference!!! >http://authors.aspalliance.com/aldotnet/examples/cd.aspx > >"Elton Wang" wrote: > >> You can still keep the delete button but change deleting >> function to collect data and save data to SessionState. >> Then popup delete page, Response.Write("<script>open >> ('delete.aspx')</script>"). In delete page, retrieve data >> from SessionState. >> >> HTH, >> >> Elton Wang >> >> >-----Original Message----- >> >I have a datagrid that brings back a number of records >> and I want to allow >> >the user to click a "delete" button in each row of the >> datagrid to delete >> >records. I originally used a <asp:ButtonColumn> for this >> and gave it a >> >CommandName attribute. This worked great. However, the >> client wants to have >> >a popup when they click on the delete button. >> > >> >So now I'm thinking that I have to create a javaScript >> function and instead >> >of using an <asp:ButtonColumn>, I'll have to use an >> <asp:TemplateColumn> with >> >an embedded <asp:button> inside of the item template. In >> this button I'm >> >imagining I'll be able to do an onclick javascript event >> handler, but I'm not >> >sure how to do this. >> > >> >I'm unsure how to create this type of functionality. >> The important piece >> >is being able to pass the data for the entire row, from >> which the delete >> >button was clicked, to the javascript function. This was >> easily done with >> >the button colum because the _ItemCommand event handler >> for the datagrid took >> >the input: DataGridCommandEventArgs, which had the data >> for the entire row. >> > >> >Any thoughts? Your help is greatly appreciated. >> > >> >-- >> >PK9 >> >. >> > >> >. > Yes, sorry if I was unclear. That's what I was referring to when I said a
javaScript popup when the user clicks on the delete button. Thanks, Paul Show quoteHide quote "Elton Wang" wrote: > So actually, you want a deleting confirmation. > > Elton Wang > > >-----Original Message----- > >That was my last option if I couldn't figure out another > way. I don't want > >to deal with another aspx page and session variables. > >I found my answer on the following website. This shows > examples to do it > >with a buttoncolumn and an itemtemplate column! Great > reference!!! > >http://authors.aspalliance.com/aldotnet/examples/cd.aspx > > > >"Elton Wang" wrote: > > > >> You can still keep the delete button but change > deleting > >> function to collect data and save data to SessionState. > >> Then popup delete page, Response.Write("<script>open > >> ('delete.aspx')</script>"). In delete page, retrieve > data > >> from SessionState. > >> > >> HTH, > >> > >> Elton Wang > >> > >> >-----Original Message----- > >> >I have a datagrid that brings back a number of records > >> and I want to allow > >> >the user to click a "delete" button in each row of the > >> datagrid to delete > >> >records. I originally used a <asp:ButtonColumn> for > this > >> and gave it a > >> >CommandName attribute. This worked great. However, > the > >> client wants to have > >> >a popup when they click on the delete button. > >> > > >> >So now I'm thinking that I have to create a javaScript > >> function and instead > >> >of using an <asp:ButtonColumn>, I'll have to use an > >> <asp:TemplateColumn> with > >> >an embedded <asp:button> inside of the item template. > In > >> this button I'm > >> >imagining I'll be able to do an onclick javascript > event > >> handler, but I'm not > >> >sure how to do this. > >> > > >> >I'm unsure how to create this type of functionality. > >> The important piece > >> >is being able to pass the data for the entire row, > from > >> which the delete > >> >button was clicked, to the javascript function. This > was > >> easily done with > >> >the button colum because the _ItemCommand event > handler > >> for the datagrid took > >> >the input: DataGridCommandEventArgs, which had the > data > >> for the entire row. > >> > > >> >Any thoughts? Your help is greatly appreciated. > >> > > >> >-- > >> >PK9 > >> >. > >> > > >> > >. > > > If that, you don't have to change from ButtonColumn to
ItemTemplate + button. Suppose your delete button (ButtonColumn) is the first column in the datagrid, just add some code in datagrid_ItemCreated event: switch (e.Item.ItemType) { case ListItemType.Header: case ListItemType.Footer: case ListItemType.Separator: case ListItemType.Pager: return; default: break; } LinkButton btn = (LinkButton)e.Item.Cells(0).Controls(0); btn.Attributes.Add("OnClick", "confirm('Are you sure you want to delete this record?');") That's it. HTH, Elton Wang >-----Original Message----- to when I said a >Yes, sorry if I was unclear. That's what I was referring Show quoteHide quote >javaScript popup when the user clicks on the delete functionality. button. > >Thanks, >Paul > >"Elton Wang" wrote: > >> So actually, you want a deleting confirmation. >> >> Elton Wang >> >> >-----Original Message----- >> >That was my last option if I couldn't figure out another >> way. I don't want >> >to deal with another aspx page and session variables. >> >I found my answer on the following website. This shows >> examples to do it >> >with a buttoncolumn and an itemtemplate column! Great >> reference!!! >> >http://authors.aspalliance.com/aldotnet/examples/cd.aspx >> > >> >"Elton Wang" wrote: >> > >> >> You can still keep the delete button but change >> deleting >> >> function to collect data and save data to SessionState. >> >> Then popup delete page, Response.Write("<script>open >> >> ('delete.aspx')</script>"). In delete page, retrieve >> data >> >> from SessionState. >> >> >> >> HTH, >> >> >> >> Elton Wang >> >> >> >> >-----Original Message----- >> >> >I have a datagrid that brings back a number of records >> >> and I want to allow >> >> >the user to click a "delete" button in each row of the >> >> datagrid to delete >> >> >records. I originally used a <asp:ButtonColumn> for >> this >> >> and gave it a >> >> >CommandName attribute. This worked great. However, >> the >> >> client wants to have >> >> >a popup when they click on the delete button. >> >> > >> >> >So now I'm thinking that I have to create a javaScript >> >> function and instead >> >> >of using an <asp:ButtonColumn>, I'll have to use an >> >> <asp:TemplateColumn> with >> >> >an embedded <asp:button> inside of the item template. >> In >> >> this button I'm >> >> >imagining I'll be able to do an onclick javascript >> event >> >> handler, but I'm not >> >> >sure how to do this. >> >> > >> >> >I'm unsure how to create this type of Show quoteHide quote >> >> The important piece >> >> >is being able to pass the data for the entire row, >> from >> >> which the delete >> >> >button was clicked, to the javascript function. This >> was >> >> easily done with >> >> >the button colum because the _ItemCommand event >> handler >> >> for the datagrid took >> >> >the input: DataGridCommandEventArgs, which had the >> data >> >> for the entire row. >> >> > >> >> >Any thoughts? Your help is greatly appreciated. >> >> > >> >> >-- >> >> >PK9 >> >> >. >> >> > >> >> >> >. >> > >> >. >
How to pass the selected row of a datagrid to another form
Datagrid Dropdownlist in default in edit mode "parent / child" datagrids How To Insert ASP.NET User Control into DataGrid Column? Adding CSS to LinkButton JavaScript confirmation HyperLink column datagrid Datagrid colum has no Dataformat property Add header text dynamically in a datagrid with templatecolumns? Can we put ActiveX Control into the DataGrid Column? |
|||||||||||||||||||||||