The Artima Developer Community
Sponsored Link

.NET Buzz Forum
ASP.NET 2.0: DataGrid Sample

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Merill Fernando

Posts: 589
Nickname: merill
Registered: Sep, 2003

Merill Fernando is an MCSD in .NET and a Microsoft Certfied Trainer
ASP.NET 2.0: DataGrid Sample Posted: Feb 10, 2004 8:33 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Merill Fernando.
Original Post: ASP.NET 2.0: DataGrid Sample
Feed Title: Merill Fernando's Blog
Feed URL: http://www.merill.net/blogxbrowsing.asmx/GetRss?
Feed Description: Merill is a Software Architect at Business Technology Alliance. Merilll is an MCSD in .NET and a Microsoft Certfied Trainer. In this feed he will be regularly posting on the challenges faced when migrating from a Microsoft DNA architecture to Microsoft .NET
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Merill Fernando
Latest Posts From Merill Fernando's Blog

Advertisement

ASP.NET 2.0 streamlines data-driven application development. This example uses the categories and product tables in SQL Server's Northwind sample database, displaying the categories in a dropdown list. This code listing uses the selected category in the dropdown list to display all the products in that category in a GridView control.

<%@ page language="C#" %>
<html>
<
headrunat="server"ID="Head1"NAME="Head1">
            <title>SqlDataSource
            Example
            </title>
</
head>
<
body>
<
formrunat="server"ID="Form1">               
      <asp:sqldatasource
           
id="categoriesDataSource"    
           
runat="server"
           
datasourcemode="DataSet"
           
connectionstring="Data
            Source=localhost;uid=sa;
            pwd=;Initial
            Catalog=Northwind;"
            selectcommand="usp_GetCategories">
      </asp:sqldatasource>
      Select Categories:
      <asp:dropdownlist
           
id="ddlCategoriesList"
           
runat="server"
           
datavaluefield="CategoryID"
           
datasourceid="categoriesDataSource"
           
autopostback="true"
            datatextfield="CategoryName">
      </asp:dropdownlist>
      <asp:sqldatasourcerunat="server"
           
id="productsDataSource"
           
datasourcemode="DataReader"
            connectionstring="Data
            Source=localhost;uid=sa;pwd=;
            Initial Catalog=Northwind;"
            selectcommand="SELECT ProductID,
            ProductName, QuantityPerUnit,
            UnitPrice  FROM Products Where
            CategoryID=@CategoryID">
            <selectparameters>
            <asp:controlparameter
                 
defaultvalue="1"
                 
name="CategoryID"
                 
propertyname="SelectedValue"
                 
controlid="ddlCategoriesList">
            </asp:controlparameter>
            </selectparameters>
      </asp:sqldatasource>
      <br/><b><br/>
      Product Details<br/></b><br/>
      <asp:gridview
           
id="productsGrid"runat="server"
           
datasourceid="productsDataSource">
      </asp:gridview>
</
form>
</
body>
</
html>

Read: ASP.NET 2.0: DataGrid Sample

Topic: Excellence in Technical writing Previous Topic   Next Topic Topic: Real World: Longhorn, part II

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use