Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to add a new record in grid
Message
From
20/07/2006 15:51:26
Evans Carl
System Answers Consulting, Inc
Big Lake, Minnesota, United States
 
 
To
20/07/2006 07:29:04
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01137978
Message ID:
01138204
Views:
13
>Hi,
>
>I have a grid and a Add button in my webform. Whenever the Add button is clicked, a new row will be created in the grid. I have refered the samples in Quickstart tutorials(Data Controls->DetailsView->VB Master-Details Insert), but the sample can only add a new record after a record in the grid was selected. As my binded table has no record initially, is there a way to do so? Please advise.

provide an event handler for the DataGrid's ItemCommand event. This event handler, "doAdd", must contain an If statement to check the CommandName property before the code to insert a new record is executed. This is because all command buttons in the DataGrid, when clicked, cause the DataGrid's ItemCommand event to fire. This includes the Edit, Update, Cancel, and Delete buttons as well. Therefore, make sure that the CommandName property that caused the ItemCommand event to fire is the same as the CommandName property of the Add button
Sub doAdd(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
  If e.CommandName = "Add" Then
     //do some work 
     

      'Rebind the DataGrid
      storeGrid.EditItemIndex = -1
      BindData()


End Sub
¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°¤º°`°º¤ø¤º°¤º°
Carl Evans
CEO & President
System Answers Consulting, Inc.
MCSD .NET, ASP.NET, C#.NET, VB.NET,
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform