Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to create New and Delete button on Web page
Message
De
14/02/2012 07:53:46
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
13/02/2012 15:26:56
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01535128
Message ID:
01535341
Vues:
38
Tony,

>Here is where I am getting stuck.
>I can't get the following code to work:
>
>Private Sub btnAddDetail_Click(ByVal sender As System.Object, e As System.EventArgs) Handles btnAddDetail.Click
>   ' Retrieve the previous Order Detail DataSet
>   Dim dsOrderDetail As DataSet = CType(Session("dsOrderDetail"), DataSet)
>   
>   ' Add a new row to the DataSet
>   Me.oOrderDetail.NewRow(dsOrderDetail, Me.oOrderDetail.TableName, New OrderDetailDefaults(Me.OrderID))
>   
>   ' Store the DataSet back into the session
>   Session("dsOrderDetail") = dsOrderDetail
>   
>   ' Set the new row for editing
>   Me.grdOrderDetail.EditIndex = dsOrderDetail.Tables(Me.oOrderDetail.TableName).Rows.Count - 1
>   
>   ' Rebind the DataGrid
>   Me.BindControl(Me.grdOrderDetail)
>End Sub
>
>This line is giving me an error saying I have to have 'new' in it.
>
>Me.grdOrderDetail.EditIndex = dsOrderDetail.Tables(Me.oOrderDetail.TableName).Rows.Count - 1
>
>I don't know what the syntax should be.
>Thanks.

Are you registering your business object in the page load? A web page is static in that any objects created are not there for a post back on the button. You will need to make sure you re-register your business objects in the page load event every time. In other words, don't wrap that in a if not page is postback. I suspect the error message is telling you the business object is not instantiated. Put a break point in your page load and in the button click and verify the business object is not null (nothing). If it isn't, then you can check in the button click which object is not valid.
Timothy Bryan
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform