I finally got it....THANKS!!!!!!!!!!!

On Apr 5, 2005 11:00 AM, Dean Fiala <[EMAIL PROTECTED]> wrote:
> Looking at your HTML, you don't actually have a button named "Delete"
> in your grid.
> 
> What you need to do is figure out which control in that column is the
> button and hard code it.  Not elegant, but .FindControl is not going
> to work in this case.
> 
> myDeleteButton = e.Item.Cells(X).Controls(Y)
> 
> where X = the column index of the delete button
> and Y = the control index
> 
> 
> 
> 
> 
> On Apr 5, 2005 10:41 AM, Mike Appenzellar <[EMAIL PROTECTED]> wrote:
> > 
> > Ok...now I get:
> > 
> > Object reference not set to an instance of an object.
> >  at
> archives.thenewspost.com.home.DataGrid_ItemCreated(Object
> Sender,
> > DataGridItemEventArgs e) in C:\Documents and
> > Settings\mappenzellar\*****\admin\home.aspx.vb:line 93
> >  at
> System.Web.UI.WebControls.DataGrid.OnItemCreated(DataGridItemEventArgs
> e)
> >  at System.Web.UI.WebControls.DataGrid.CreateItem(Int32
> itemIndex,
> > Int32 dataSourceIndex, ListItemType itemType, Boolean dataBind, Object
> > dataItem, DataGridColumn[] columns, TableRowCollection rows,
> > PagedDataSource pagedDataSource)
> >  at
> System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean
> > useDataSource)
> >  at
> System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs
> e)
> >  at System.Web.UI.WebControls.BaseDataList.DataBind()
> >  at archives.thenewspost.com.home.BindDataGrid() in
> C:\Documents and
> > Settings\mappenzellar\*****\admin\home.aspx.vb:line 84
> >  at archives.thenewspost.com.home.Page_Load(Object
> sender, EventArgs
> > e) in C:\Documents and
> > Settings\mappenzellar\*****\admin\home.aspx.vb:line 45
> >  at System.Web.UI.Control.OnLoad(EventArgs e)
> >  at System.Web.UI.Control.LoadRecursive()
> >  at System.Web.UI.Page.ProcessRequestMain()
> > 
> > line 93 is "myDeleteButton.Attributes.Add("onclick", "return
> > confirm('Are you sure you want to delete this company?');")"
> > 
> > which is part of:
> > 
> > Sub DataGrid_ItemCreated(ByVal Sender As Object, ByVal e As
> > DataGridItemEventArgs) Handles myDataGrid.ItemCreated
> >        Select Case e.Item.ItemType
> >            Case ListItemType.Item, ListItemType.AlternatingItem,
> > ListItemType.EditItem
> >                Dim myDeleteButton As Button
> >                myDeleteButton = e.Item.FindControl("Delete")
> >                myDeleteButton.Attributes.Add("onclick", "return
> > confirm('Are you sure you want to delete this company?');")
> > 
> >        End Select
> >    End Sub
> > 
> > Could I have somehting else wrong somewhere???
> > 
> > On Apr 5, 2005 10:21 AM, Dean Fiala <[EMAIL PROTECTED]> wrote:
> > > Why did you change back to this?
> > > ...
> > > OnItemCommand="DataGrid_ItemCreated"
> > >
> > > Leave that pointing to the Delete sub
> > >
> > > as I mentioned earlier
> > >
> > > OnItemCommand is for CLICKING, not creating
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On Apr 5, 2005 10:09 AM, Mike Appenzellar <[EMAIL PROTECTED]>
> wrote:
> > > >
> > > > Now I get the " BC30408: Method 'Public Sub
> > > > DataGrid_ItemCreated(Sender As Object, e As
> > > > System.Web.UI.WebControls.DataGridItemEventArgs)'
> does
> > > not have the
> > > > same signature as delegate 'Delegate Sub
> > > > DataGridCommandEventHandler(source As Object, e As
> > > > System.Web.UI.WebControls.DataGridCommandEventArgs)'.
> > > > "
> > > >
> > > > OnItemCommand="DataGrid_ItemCreated"
> > > >
> > > > Sub DataGrid_ItemCreated(ByVal Sender As Object, ByVal e As
> > > > DataGridItemEventArgs) Handles myDataGrid.ItemCreated
> > > >        Select Case e.Item.ItemType
> > > >            Case ListItemType.Item, ListItemType.AlternatingItem,
> > > > ListItemType.EditItem
> > > >                Dim myDeleteButton As Button
> > > >                myDeleteButton = e.Item.FindControl("Delete")
> > > >                myDeleteButton.Attributes.Add("onclick", "return
> > > > confirm('Are you sure you want to delete this company?');")
> > > >
> > > >        End Select
> > > >    End Sub
> > > >
> > > > On Apr 5, 2005 9:30 AM, Dean Fiala <[EMAIL PROTECTED]> wrote:
> > > > > First thing, check your page source.  Is the javascript for the
> prompt
> > > > > being created?
> > > > >
> > > > > If not, it is probably because your DataGrid_ItemCreated is not
> > > > > getting called and addding the attribute.
> > > > >
> > > > > Add the Handles code so that the ItemCreated command to be called
> when
> > > > > the grid is created.
> > > > >
> > > > > Sub DataGrid_ItemCreated(ByVal Sender As Object, ByVal e As
> > > > > DataGridItemEventArgs) Handles myDataGrid.ItemCreated
> > > > >
> > > > >
> > > > >
> > > > > On Apr 5, 2005 9:18 AM, Mike Appenzellar <[EMAIL PROTECTED]>
> wrote:
> > > > > >
> > > > > > When OnItemCommand="myDataGrid_Delete" is set, it
> > > simply
> > > > > ignores the
> > > > > > prompt code and deletes the record. I have tried adding an
> > > > > > ondeleteCommand to my datagrid properties and that doesn't help
> > > > > > either.
> > > > > >
> > > > > > On Apr 5, 2005 8:53 AM, Dean Fiala <[EMAIL PROTECTED]> wrote:
> > > > > > > because OnItemCommand I believe is called for all click events
> in a
> > > grid
> > > > > > > item.
> > > > > > >
> > > > > > >
> > > > > > > On Apr 5, 2005 8:52 AM, Dean Fiala <[EMAIL PROTECTED]> wrote:
> > > > > > > > OnItemCommand="DataGrid_ItemCreated"
> > > > > > > >
> > > > > > > > is your problem
> > > > > > > >
> > > > > > > > OnItemCommand is called when you click on item, not when you
> > > create
> > > > > it.
> > > > > > > >
> > > > > > > > Since you seem to have the other click events handled, change
> it
> > > to...
> > > > > > > >
> > > > > > > > OnItemCommand="myDataGrid_Delete"
> > > > > > > >
> > > > > > > > Now, you might have trap for the delete event
> > > > > > > >
> > > > > > > >
> > > > > > > > On Apr 5, 2005 8:43 AM, Mike Appenzellar
> <[EMAIL PROTECTED]>
> > > > > wrote:
> > > > > > > > >
> > > > > > > > > Having a problem with a datagrid delete prompt. I want it so
> > > that if
> > > > > > > > > the user clicks on delete that they get the javascript...are
> you
> > > > > sure
> > > > > > > > > message. I have read about 3 different sites on how to do
> this,
> > > but
> > > > > I
> > > > > > > > > keep getting the following error:
> > > > > > > > >
> > > > > > > > > "BC30408: Method 'Public Sub DataGrid_ItemCreated(Sender As
> > > Object,
> > > > > e
> > > > > > > > > As
> > > > > System.Web.UI.WebControls.DataGridItemEventArgs)'
> > > > > > > does not have the
> > > > > > > > > same signature as delegate 'Delegate Sub
> > > > > > > > > DataGridCommandEventHandler(source As
> Object, e
> > > As
> > > > > > > > >
> > > > >
> System.Web.UI.WebControls.DataGridCommandEventArgs)'.
> > > > > > > > > "
> > > > > > > > >
> > > > > > > > > Sub DataGrid_ItemCreated(ByVal Sender As Object, ByVal e As
> > > > > > > > > DataGridItemEventArgs)
> > > > > > > > >        Select Case e.Item.ItemType
> > > > > > > > >            Case ListItemType.Item,
> ListItemType.AlternatingItem,
> > > > > > > > > ListItemType.EditItem
> > > > > > > > >                Dim myDeleteButton As Button
> > > > > > > > >                myDeleteButton = e.Item.FindControl("Delete")
> > > > > > > > >                myDeleteButton.Attributes.Add("onclick",
> "return
> > > > > > > > > confirm('Are you sure you want to delete this company?');")
> > > > > > > > >
> > > > > > > > >        End Select
> > > > > > > > >    End Sub
> > > > > > > > >
> > > > > > > > >    Sub myDataGrid_Delete(ByVal sender As Object, ByVal e As
> > > > > > > > > DataGridCommandEventArgs)
> > > > > > > > >        Dim intID As Integer
> > > > > > > > >        Dim Conn As SqlConnection
> > > > > > > > >        Dim cmdSql As SqlCommand
> > > > > > > > >        Dim strSql As String
> > > > > > > > >        intID = myDataGrid.DataKeys(e.Item.ItemIndex)
> > > > > > > > >        Conn = New
> > > > > > > SqlConnection(AppSettings("sqlConnect"))
> > > > > > > > >        strSql = "DELETE FROM USERS WHERE [EMAIL PROTECTED]"
> > > > > > > > >        cmdSql = New SqlCommand(strSql, Conn)
> > > > > > > > >        cmdSql.Parameters.Add("@id", intID)
> > > > > > > > >        Conn.Open()
> > > > > > > > >        cmdSql.ExecuteNonQuery()
> > > > > > > > >        Conn.Close()
> > > > > > > > >        myDataGrid.EditItemIndex = -1
> > > > > > > > >        BindDataGrid()
> > > > > > > > >    End Sub
> > > > > > > > >
> > > > > > > > > <asp:datagrid id="myDataGrid" runat="server"
> > > > > > > > > AutoGenerateColumns="False" DataKeyField="id"
> CssClass="body"
> > > > > > > > > BorderColor="#999999" BorderStyle="None" BorderWidth="1px"
> > > > > > > > > BackColor="White" CellPadding="3" GridLines="Vertical"
> > > > > > > > > OnCancelCommand="myDataGrid_CancelCommand"
> > > > > > > > > OnUpdateCommand="myDataGrid_UpdateCommand"
> > > > > > > > > OnEditCommand="myDataGrid_EditCommand"
> > > > > > > > > OnItemCommand="DataGrid_ItemCreated">
> > > > > > > > >
> > > > > > > > > <FooterStyle ForeColor="Black"
> > > > > > > BackColor="#CCCCCC"></FooterStyle>
> > > > > > > > > <SelectedItemStyle Font-Bold="True" ForeColor="White"
> > > > > > > > > backColor="#008A8C"></SelectedItemStyle>
> > > > > > > > >
> > > > > > > > > <AlternatingItemStyle
> > > > > > > BackColor="#DCDCDC"></AlternatingItemStyle>
> > > > > > > > >
> > > > > > > > > <ItemStyle ForeColor="Black"
> > > > > > > BackColor="#EEEEEE"></ItemStyle>
> > > > > > > > >
> > > > > > > > > <HeaderStyle Font-Bold="True" ForeColor="White"
> > > CssClass="bodyrev"
> > > > > > > > > BackColor="#000084"></HeaderStyle>
> > > > > > > > >
> > > > > > > > > <Columns>
> > > > > > > > >      <asp:BoundColumn DataField="advertiser" ReadOnly="True"
> > > > > > > > > HeaderText="ADVERTISER"></asp:BoundColumn>
> > > > > > > > >      <asp:TemplateColumn>
> > > > > > > > >
> > > > > > > > >      <EditItemTemplate>
> > > > > > > > >            <asp:TextBox ID="txtAdvertiser" Text='<%#
> > > > > > > > > Container.DataItem("advertiser") %>'
> > > runat="server"></asp:TextBox>
> > > > > > > > >      </EditItemTemplate>
> > > > > > > > >      </asp:TemplateColumn>
> > > > > > > > >
> > > > > > > > > <asp:BoundColumn DataField="username" ReadOnly="True"
> > > > > > > > > HeaderText="USERNAME"></asp:BoundColumn>
> > > > > > > > >
> > > > > > > > > <asp:TemplateColumn>
> > > > > > > > >      <EditItemTemplate>
> > > > > > > > >      <asp:TextBox ID="txtUsername" Text='<%#
> > > > > > > > > Container.DataItem("username") %>'
> runat="server"></asp:TextBox>
> > > > > > > > >      </EditItemTemplate>
> > > > > > > > > </asp:TemplateColumn>
> > > > > > > > >
> > > > > > > > > <asp:EditCommandColumn ButtonType="LinkButton"
> > > UpdateText="Update"
> > > > > > > > > HeaderText="EDIT" CancelText="Cancel!"
> > > > > > > > > EditText="Edit"></asp:EditCommandColumn>
> > > > > > > > >
> > > > > > > > > <asp:ButtonColumn Text="Delete" HeaderText="DELETE"
> > > > > CommandName="Delete"
> > > > > > > />
> > > > > > > > >
> > > > > > > > > </Columns>
> > > > > > > > >
> > > > > > > > > <PagerStyle HorizontalAlign="Center" ForeColor="Black"
> > > > > > > > > BackColor="#999999"
> > > > > Mode="NumericPages"></PagerStyle>
> > > > > > > > > </asp:datagrid>
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Yahoo! Groups Links
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Dean Fiala
> > > > > > > > Very Practical Software, Inc
> > > > > > > > http://www.vpsw.com
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Dean Fiala
> > > > > > > Very Practical Software, Inc
> > > > > > > http://www.vpsw.com
> > > > > > >
> > > > > > > ________________________________
> > > > > > > Yahoo! Groups Links
> > > > > > >
> > > > > > > To visit your group on the web, go to:
> > > > > > >
> > > http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
> > > > > > >
> > > > > > > To unsubscribe from this group, send an email to:
> > > > > > >
> [EMAIL PROTECTED]
> > > > > > >
> > > > > > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service.
> > > > > >
> > > > > >
> > > > > > Yahoo! Groups Links
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Dean Fiala
> > > > > Very Practical Software, Inc
> > > > > http://www.vpsw.com
> > > > >
> > > > > ________________________________
> > > > > Yahoo! Groups Links
> > > > >
> > > > > To visit your group on the web, go to:
> > > > >
> http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
> > > > >
> > > > > To unsubscribe from this group, send an email to:
> > > > > [EMAIL PROTECTED]
> > > > >
> > > > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> > > >
> > > > Yahoo! Groups Links
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > Dean Fiala
> > > Very Practical Software, Inc
> > > http://www.vpsw.com
> > >
> > > ________________________________
> > > Yahoo! Groups Links
> > >
> > > To visit your group on the web, go to:
> > > http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
> > >
> > > To unsubscribe from this group, send an email to:
> > > [EMAIL PROTECTED]
> > >
> > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> > 
> > Yahoo! Groups Links
> > 
> > 
> > 
> > 
> > 
> 
> 
> -- 
> Dean Fiala
> Very Practical Software, Inc
> http://www.vpsw.com
> 
> ________________________________
> Yahoo! Groups Links
> 
> To visit your group on the web, go to:
> http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
>   
> To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
>   
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to