p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

aspx thread: Select from a dropdownlist Display in a DataGrid

Message #1 by "Douglas S. Tarr" <douglas.tarr@l...> on Tue, 23 Jul 2002 23:18:53
I am attempting to create a web form that uses a web service to search a 
database.  The web form has a dropdownlist that is populated by the 
service. I want to be able to select an item from the dropdownlist and 
have it refresh the page, still showing the selected item in the 
dropdownlist and now showing a datagrid of additional information, 
specific to the selection. No datagrid shows until an item is selected 
from the dropdownlist.

I am using VS.Net C#, latest production release. I am using a 
dropdownlist, a dataview, a dataset, and a datagrid.  What I get is the 
dropdownlist to populate and I get the complete list of items in the 
datagrid.  There is no connection between by dropdown and the datagrid. 
When I select an item in the dropdown, the page refreshes back to the 
original first item in the dropdown list ( I have the AutoPostBack set to 
true on the dropdown)  


using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace SearchClientNXT
	/// <summary>
	/// Summary description for WebForm1.
	/// </summary>
	public class WebForm1 : System.Web.UI.Page
		protected System.Web.UI.WebControls.DropDownList 
		protected SearchClientNXT.localhost.dsClaimInfo 
		protected System.Data.DataView DataView1;
		protected System.Web.UI.WebControls.DataGrid DataGrid1;
		private void Page_Load(object sender, System.EventArgs e)
				SearchClientNXT.localhost.Service1 ws = 
			 new SearchClientNXT.localhost.Service1();
			ws.Credentials = 
//GetClaim method queries DB and returns 2 columns: NUM_CLM and CLMNT 
			if (!IsPostBack)

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
			// CODEGEN: This call is required by the ASP.NET 
Web Form Designer.
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
			this.dsClaimInfo1 = new 
			this.DataView1 = new System.Data.DataView();
			// dsClaimInfo1
			this.dsClaimInfo1.DataSetName = "dsClaimInfo";
			this.dsClaimInfo1.Locale = new 
= "http://www.tempuri.org/dsClaimInfo.xsd";
			// DataView1
			this.DataView1.RowFilter = "NUM_CLM like \'%\'";
			this.DataView1.Table = this.dsClaimInfo1.LLXCLAMT;
			this.Load += new System.EventHandler


Message #2 by Immanuel_L'heureux@C... on Tue, 23 Jul 2002 15:25:15 -0700
This is a multipart message in MIME format.
--=_alternative 007B4FB188256BFF_
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit

Did you try putting this :



 if (!IsPostBack) {



  Return to Index