>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
storeGrid.EditItemIndex = -1
BindData()
End Sub
¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°¤º°`°º¤ø¤º°¤º°
Carl Evans
CEO & President
System Answers Consulting, Inc.
MCSD .NET, ASP.NET, C#.NET, VB.NET,