DotNet Tutorials

Server Intellect

 GridView and DetailsView control in ASP.NET 2.0(VB.NET)

This tutorial will show you how to use a GridView control in combination with a DetailsView control in ASP.NET and VB.Net 2.0 to display master-detail information.

To refresh the GridView control after a new record is inserted into DetailsView control

Try Server Intellect for Windows Server Hosting. Quality and Quantity!

Sub CustomerDetail_ItemInserted(ByVal sender As Object, _
ByVal e As DetailsViewInsertedEventArgs)
CustomersView.DataBind()
End Sub

Insert the values entered

Sub CustomerDetail_ItemUpdating(ByVal sender As Object, _
ByVal e As DetailsViewUpdateEventArgs)
For i As Integer = 0 To e.NewValues.Count - 1
If e.NewValues(i) IsNot Nothing Then
e.NewValues(i) = Server.HtmlEncode(e.NewValues(i).ToString())
End If
Next
End Sub

Server Intellect assists companies of all sizes with their hosting needs by offering fully configured server solutions coupled with proactive server management services. Server Intellect specializes in providing complete internet-ready server solutions backed by their expert 24/365 proactive support team.

DataSource setting

<asp:SqlDataSource ID="Customers" runat="server"
ConnectionString=
"<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [CompanyName], [ContactName], [CustomerID]
FROM [Customers]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="Details"
ConnectionString=
"<%$ ConnectionStrings:NorthwindConnectionString %>"
runat="server"
SelectCommand="SELECT * FROM [Customers]
WHERE ([CustomerID] = @CustomerID)"

InsertCommand="INSERT INTO [Customers] ([CustomerID],
[CompanyName], [ContactName], [ContactTitle], [Address],
[City], [Region], [PostalCode], [Country], [Phone], [Fax])
VALUES (@CustomerID, @CompanyName, @ContactName, @ContactTitle,
@Address, @City, @Region, @PostalCode, @Country, @Phone, @Fax)"
UpdateCommand="UPDATE [Customers] SET [CompanyName] = @CompanyName,
[ContactName] = @ContactName, [ContactTitle] = @ContactTitle,
[Address] = @Address, [City] = @City, [Region] = @Region,
[PostalCode] = @PostalCode, [Country] = @Country,
[Phone] = @Phone, [Fax] = @Fax
WHERE [CustomerID] = @CustomerID">



Looking for the C#.NET 2005 Version? Click Here!

Looking for more ASP.NET Tutorials? Click Here!

If you're looking for a really good web host, try Server Intellect - we found the setup procedure and control panel, very easy to adapt to and their IT team is awesome!

Download Project Source - Enter your Email to be emailed a link to download the Full Source Project used in this Tutorial!



100% SPAM FREE! We will never sell or rent your email address!
 
123 ASP

411 ASP

Dot Net Freaks

Server Intellect