Server Intellect
 
Home   Asp.Net Tutorials   What's New   Newsletter   More Resources
Tutorial RSS
 
  Categories
Advanced Technologies
AJAX
Internet Browsers
Charts
Controls
Database
Email
Error Handling
File
Graphics
Website Navigation
Network
Performance
User Interface and Themes
Validation
Visual Web Developer
Web Services
XML
Suggest Tutorial


Navigator: Home - Tutorials - Controls - GridView and DetailsView control in ASP.NET 2.0(VB.NET)
GridView and DetailsView control in ASP.NET 2.0(VB.NET)

ASP.Net 4.0 Tutorials V4
Server Intellect Cloud Hosting

ASP.NET Controls Tutorial

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

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

We moved our web sites to Server Intellect and have found them to be incredibly professional. Their setup is very easy and we were up and running in no time.

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

I just signed up at Server Intellect and couldn't be more pleased with my Windows Server! Check it out and see for yourself.

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!

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!



 
  Developer Resources







Server Intellect Rocks