Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Delete on DataGrid
Message
From
05/02/2005 20:00:07
 
 
To
23/01/2005 14:24:43
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00979833
Message ID:
00984252
Views:
25
Here is one of mine ;
    Private Sub grdProdType_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles grdProdType.DeleteCommand
        Dim strDelSQL As String

        strDelSQL = "DELETE FROM ProductType where ProdType_ID = " & Val(e.Item.Cells(2).Text.ToString)

        Dim oCn As New SqlConnection(SqlCn.ConnectionString.ToString)
        Dim dbComm As New SqlCommand(strDelSQL, oCn)
        oCn.Open()
        dbComm.ExecuteNonQuery()
        oCn.Close()
        BindProductTypeGrid()
    End Sub
>Hi , does anybody have an idea on how to delete records using data grid? current i use the button column and insert the following code . I receive and error of "Object reference not set to an instance of an object" probably on "rowChange.Delete();" is check the MSDN and seems to exact. did i miss something? tnx.
>
>
>===============
>
>private void grdUserGroup_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
> {
>this.oConn.ConnectionString=ConfigurationSettings.AppSettings["connectionString"];
>try
>{
> // Open COnnection
> this.oConn.Open();
>
>
> dsUserCompany.CustEmpVendorRow rowChange;
>
> int key = int.Parse( (this.grdUserGroup.DataKeys[e.Item.ItemIndex].ToString() ));
> rowChange= this.dsUserCompany1.CustEmpVendor.FindByPkCustEmpVenID(key );
> rowChange.Delete();
> this.sqlDaUseCompany.Update(this.dsUserCompany1);
>
> this.oConn.Close();
>}
>catch (Exception ex)
> {
> Response.Write(ex.Message);
> }
>
>
>}
~Joe Johnston USA

"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams

Previous
Reply
Map
View

Click here to load this message in the networking platform