very Urgent

Results 1 to 2 of 2

Thread: very Urgent

  1. #1
    Join Date
    Dec 1969

    Default very Urgent

    Hi,<BR>I&#039;m new to ASP.Net. My problem is <BR><BR>I&#039;ve two listboxes consisting of countries & One Button named Compare.When i select one country in first listbox and another country in another and press compare i need to get description of the both countries in the same page with common charateristics listed (say for example population ).Can any one suggest me a sample code for atleast one comparison.<BR><BR>Very Urgent SAMPLE CODE

  2. #2
    Join Date
    Dec 1969

    Default RE: very Urgent

    I dont know you tried is this one or not?<BR><BR>here i have 2 list boxes(lstOne and lstTwo)and one button<BR><BR>then check this code:<BR><BR>using System;<BR>using System.Collections;<BR>using System.ComponentModel;<BR>using System.Data;<BR>using System.Drawing;<BR>using System.Web;<BR>using System.Web.SessionState;<BR>using System.Web.UI;<BR>using System.Web.UI.WebControls;<BR>using System.Web.UI.HtmlControls;<BR><BR>namespace FileUpLoad<BR>{<BR> /// &#060;summary&#062;<BR> /// Summary description for _4GuysTry.<BR> /// &#060;/summary&#062;<BR> public class _4GuysTry : System.Web.UI.Page<BR> {<BR> protected System.Web.UI.WebControls.ListBox lstOne;<BR> protected System.Web.UI.WebControls.ListBox lstTwo;<BR> protected System.Web.UI.WebControls.Button Button1;<BR> int[] population={1000,2000,3000,4000};<BR> <BR> private void Page_Load(object sender, System.EventArgs e)<BR> {<BR> <BR> //string[] state1 ={"kerala","karnataka","AndraPradesh","TamilNadu"} ;<BR> //string[] state2 = {"Assam","Nagaland","Orissa","Punjab"};<BR><BR> lstOne.Items.Add("kerala");<BR> lstOne.Items.Add("karnataka");<BR> lstOne.Items.Add("AndraPradesh");<BR> lstOne.Items.Add("TamilNadu");<BR><BR><BR> lstTwo.Items.Add("kerala");<BR> lstTwo.Items.Add("karnataka");<BR> lstTwo.Items.Add("AndraPradesh");<BR> lstTwo.Items.Add("TamilNadu");<BR><BR><BR><BR> }<BR><BR> <BR><BR> #region Web Form Designer generated code<BR> override protected void OnInit(EventArgs e)<BR> {<BR> //<BR> // CODEGEN: This call is required by the ASP.NET Web Form Designer.<BR> //<BR> InitializeComponent();<BR> base.OnInit(e);<BR> }<BR> <BR> /// &#060;summary&#062;<BR> /// Required method for Designer support - do not modify<BR> /// the contents of this method with the code editor.<BR> /// &#060;/summary&#062;<BR> private void InitializeComponent()<BR> { <BR> this.Button1.Click += new System.EventHandler(this.Button1_Click);<BR> this.Load += new System.EventHandler(this.Page_Load);<BR><BR> }<BR> #endregion<BR><BR> private void Button1_Click(object sender, System.EventArgs e)<BR> {<BR> if(lstOne.SelectedValue.ToString()== lstTwo.SelectedValue.ToString())<BR> {<BR> int ind = lstOne.SelectedIndex;<BR> switch(ind)<BR> {<BR> case 0:<BR> Response.Write("Population of"+lstOne.SelectedValue.ToString()+" is : "+ population[0]);<BR> break;<BR> case 1:<BR> Response.Write("Population of"+lstOne.SelectedValue.ToString()+" is : "+ population[1]);<BR> break;<BR> case 2:<BR> Response.Write("Population of"+lstOne.SelectedValue.ToString()+" is : "+ population[2]);<BR> break;<BR> case 3:<BR> Response.Write("Population of"+lstOne.SelectedValue.ToString()+" is : "+ population[3]);<BR> break;<BR> }<BR> }<BR> else<BR> {<BR> Response.Write("your selection doent match");<BR> }<BR> }<BR> }<BR>}<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts