autogeneration

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shalini166
    New Member
    • Apr 2008
    • 70

    autogeneration

    Autogeneration is set to particular field.example group code.
    after i delete or update that rows. the group code is not updated.
  • balame2004
    New Member
    • Mar 2008
    • 142

    #2
    Hi Shalini,

    We can not explicitly set the value to a field which is declared as autogenration key. Value is automatically generated by the database itself.

    Regards,
    Balaji U

    Comment

    • shalini166
      New Member
      • Apr 2008
      • 70

      #3
      hi

      I need to populate the respective states from the states dropdownlist when a user chooses a country from the country dropdownlist. Similary when the state is selected from the states dropdownlist the corresponding cities should get displayed in the cities dropdownlistbox . Pls provide me with the coding? Here is the following code which i developed.

      example(c#.net)
      [code=vbnet]
      Private Sub fillcountry()
      ddlcountry.Item s.Add("India")
      ddlcountry.Item s.Add("UK")
      ddlcountry.Item s.Add("USA")
      ddlcountry.Item s.Add("Germany" )
      End Sub
      Private Sub fillstate()
      'list of states in india
      ddlstate.Items. Add("Tamilnadu" )
      ddlstate.Items. Add("AndhraPrad esh")
      ddlstate.Items. Add("Kerela")
      ddlstate.Items. Add("MadhyaPrad esh")
      'list of states in UK
      ddlstate.Items. Add("Yorkshire" )
      ddlstate.Items. Add("London")
      ddlstate.Items. Add("Surrey")
      ddlstate.Items. Add("Manchester shire")
      'list of states in USA
      ddlstate.Items. Add("Florida")
      ddlstate.Items. Add("California ")
      ddlstate.Items. Add("Atlanta")
      ddlstate.Items. Add("Chicago")
      'list of states in Germany
      ddlstate.Items. Add("Berlin")
      ddlstate.Items. Add("Hamberg")
      ddlstate.Items. Add("Frankfurt" )
      ddlstate.Items. Add("Munich")
      End Sub
      Private Sub fillcity()
      'list of cities in india
      ddlstate.Items. Add("Mumbai")
      ddlstate.Items. Add("Chennai")
      ddlstate.Items. Add("Kolkatta")
      ddlstate.Items. Add("Delhi")
      'list of cities in UK
      ddlstate.Items. Add("Yorkshire" )
      ddlstate.Items. Add("London")
      ddlstate.Items. Add("Surrey")
      ddlstate.Items. Add("Manchester shire")
      'list of cities in USA
      ddlstate.Items. Add("Florida")
      ddlstate.Items. Add("California ")
      ddlstate.Items. Add("Atlanta")
      ddlstate.Items. Add("Chicago")
      'list of cities in Germany
      ddlstate.Items. Add("Berlin")
      ddlstate.Items. Add("Hamberg")
      ddlstate.Items. Add("Frankfurt" )
      ddlstate.Items. Add("Munich")
      End Sub[/code]

      pls help me
      Last edited by Frinavale; Apr 16 '08, 01:10 PM. Reason: added [code] tags

      Comment

      • balame2004
        New Member
        • Mar 2008
        • 142

        #4
        Originally posted by shalini166
        hi

        I need to populate the respective states from the states dropdownlist when a user chooses a country from the country dropdownlist. Similary when the state is selected from the states dropdownlist the corresponding cities should get displayed in the cities dropdownlistbox . Pls provide me with the coding? Here is the following code which i developed.

        example(c#.net)

        Private Sub fillcountry()
        ddlcountry.Item s.Add("India")
        ddlcountry.Item s.Add("UK")
        ddlcountry.Item s.Add("USA")
        ddlcountry.Item s.Add("Germany" )
        End Sub
        Private Sub fillstate()
        'list of states in india
        ddlstate.Items. Add("Tamilnadu" )
        ddlstate.Items. Add("AndhraPrad esh")
        ddlstate.Items. Add("Kerela")
        ddlstate.Items. Add("MadhyaPrad esh")
        'list of states in UK
        ddlstate.Items. Add("Yorkshire" )
        ddlstate.Items. Add("London")
        ddlstate.Items. Add("Surrey")
        ddlstate.Items. Add("Manchester shire")
        'list of states in USA
        ddlstate.Items. Add("Florida")
        ddlstate.Items. Add("California ")
        ddlstate.Items. Add("Atlanta")
        ddlstate.Items. Add("Chicago")
        'list of states in Germany
        ddlstate.Items. Add("Berlin")
        ddlstate.Items. Add("Hamberg")
        ddlstate.Items. Add("Frankfurt" )
        ddlstate.Items. Add("Munich")
        End Sub
        Private Sub fillcity()
        'list of cities in india
        ddlstate.Items. Add("Mumbai")
        ddlstate.Items. Add("Chennai")
        ddlstate.Items. Add("Kolkatta")
        ddlstate.Items. Add("Delhi")
        'list of cities in UK
        ddlstate.Items. Add("Yorkshire" )
        ddlstate.Items. Add("London")
        ddlstate.Items. Add("Surrey")
        ddlstate.Items. Add("Manchester shire")
        'list of cities in USA
        ddlstate.Items. Add("Florida")
        ddlstate.Items. Add("California ")
        ddlstate.Items. Add("Atlanta")
        ddlstate.Items. Add("Chicago")
        'list of cities in Germany
        ddlstate.Items. Add("Berlin")
        ddlstate.Items. Add("Hamberg")
        ddlstate.Items. Add("Frankfurt" )
        ddlstate.Items. Add("Munich")
        End Sub

        pls help me

        Hi,

        Try this:

        Code:
        //Global Variable
        private static DataTable CountryStateCityTable=new DataTable();
        
        
        page_load(...)
        {
         
        //Setting autopostback property to true so page is posted back to the server whenever an event is being fired.
        this.CountryListBox.AutoPostBack=true;
        this.StateListBox.AutoPostBack=true;
        this.CityListBox.AutoPostBack=true;
        
        //City,State,Country
        
        CountryStateCityTable.Columns.Add("Country");
        CountryStateCityTable.Columns.Add("State");
        CountryStateCityTable.Columns.Add("City");			
        
        CountryStateCityTable.Rows.Add(new string[]{"India","Tamilnadu","Chennai"});
        CountryStateCityTable.Rows.Add(new string[]{"India","Tamilnadu","Vellore"});
        CountryStateCityTable.Rows.Add(new string[]{"India","Tamilnadu","Koimbotore"});
        CountryStateCityTable.Rows.Add(new string[]{"India","Tamilnadu","Madurai"});
        CountryStateCityTable.Rows.Add(new string[]{"India","Tamilnadu","Thiruchy"});
        CountryStateCityTable.Rows.Add(new string[]{"India","Kerala","Cochin"});
        CountryStateCityTable.Rows.Add(new string[]{"India","Kerala","Ernakulam"});
        CountryStateCityTable.Rows.Add(new string[]{"India","Kerala","Kolikode"});
        CountryStateCityTable.Rows.Add(new string[]{"India","Karnataka","Bangalore"});
        CountryStateCityTable.Rows.Add(new string[]{"India","Karnataka","Mysore"});
        CountryStateCityTable.Rows.Add(new string[]{"India","Karnataka","Mangalore"});
        
        CountryStateCityTable.Rows.Add(new string[]{"United States","New Jercy","New York"});
        CountryStateCityTable.Rows.Add(new string[]{"United States","New Jercy","North Carolina"});
        CountryStateCityTable.Rows.Add(new string[]{"United States","Colambia","Colambia City"});
        CountryStateCityTable.Rows.Add(new string[]{"United States","Washington","Washington"});
        CountryStateCityTable.Rows.Add(new string[]{"Pakistan","Sindhu","Islamabad"});
        CountryStateCityTable.Rows.Add(new string[]{"Pakistan","Balusistan","Peshavur"});
        CountryStateCityTable.Rows.Add(new string[]{"Pakistan","Balusistan","Hyderabad"});
        CountryStateCityTable.Rows.Add(new string[]{"Pakistan","Punjab","Karachi"});
        
        			
        this.CountryListBox.DataSource=new DataView(this.CountryStateCityTable).ToTable(true,"Country").DefaultView;
        this.CountryListBox.ValueMember="Country";
        this.CountryListBox.DisplayMember="Country";
        
        }
        
        
        
        
        private void StateListBox_SelectedValueChanged(...)
        {
        	try
        	{
        		DataView view=new DataView(this.CountryStateCityTable);
        		view.RowFilter="Country='"+this.CountryListBox.SelectedItem.Text+"' AND State='"+this.StateListBox.SelectedItem.Text+"'";			
        		this.CityListBox.DataSource=viewToTable(true,"City").DefaultView;;
        		this.CityListBox.DisplayMember="City";
        		this.CityListBox.ValueMember="City";
        	}
        	catch(Exception exc)
        	{
                      Responce.Write(exc.Message);
        	}
        }
        
        private void CountryListBox_SelectedValueChanged(...)
        {
               try
        	{
        	    DataView view=new DataView(this.CountryStateCityTable);
                    view.RowFilter="Country='"+this.CountryListBox.SelectedItem.Text+"'";		
        	    this.StateListBox.DataSource=view.ToTable(true,"State").DefaultView;
        	    this.StateListBox.DisplayMember="State";
        	    this.StateListBox.ValueMember="State";
        	}
        	catch(Exception exc)
        	{
                   Responce.Write(exc.Message);
        	}
        }

        - Balaji U

        Comment

        • balame2004
          New Member
          • Mar 2008
          • 142

          #5
          I have added IsPostBack condition here.



          Code:
          //Global Variable
          private static DataTable CountryStateCityTable=new DataTable();
          
          
          page_load(...)
          {
           
          if(!IsPostBack)
          {
          //Setting autopostback property to true so page is posted back to the server whenever an event is being fired.
          this.CountryListBox.AutoPostBack=true;
          this.StateListBox.AutoPostBack=true;
          this.CityListBox.AutoPostBack=true;
          
          //City,State,Country
          
          CountryStateCityTable.Columns.Add("Country");
          CountryStateCityTable.Columns.Add("State");
          CountryStateCityTable.Columns.Add("City");			
          
          CountryStateCityTable.Rows.Add(new string[]{"India","Tamilnadu","Chennai"});
          CountryStateCityTable.Rows.Add(new string[]{"India","Tamilnadu","Vellore"});
          CountryStateCityTable.Rows.Add(new string[]{"India","Tamilnadu","Koimbotore"});
          CountryStateCityTable.Rows.Add(new string[]{"India","Tamilnadu","Madurai"});
          CountryStateCityTable.Rows.Add(new string[]{"India","Tamilnadu","Thiruchy"});
          CountryStateCityTable.Rows.Add(new string[]{"India","Kerala","Cochin"});
          CountryStateCityTable.Rows.Add(new string[]{"India","Kerala","Ernakulam"});
          CountryStateCityTable.Rows.Add(new string[]{"India","Kerala","Kolikode"});
          CountryStateCityTable.Rows.Add(new string[]{"India","Karnataka","Bangalore"});
          CountryStateCityTable.Rows.Add(new string[]{"India","Karnataka","Mysore"});
          CountryStateCityTable.Rows.Add(new string[]{"India","Karnataka","Mangalore"});
          
          CountryStateCityTable.Rows.Add(new string[]{"United States","New Jercy","New York"});
          CountryStateCityTable.Rows.Add(new string[]{"United States","New Jercy","North Carolina"});
          CountryStateCityTable.Rows.Add(new string[]{"United States","Colambia","Colambia City"});
          CountryStateCityTable.Rows.Add(new string[]{"United States","Washington","Washington"});
          CountryStateCityTable.Rows.Add(new string[]{"Pakistan","Sindhu","Islamabad"});
          CountryStateCityTable.Rows.Add(new string[]{"Pakistan","Balusistan","Peshavur"});
          CountryStateCityTable.Rows.Add(new string[]{"Pakistan","Balusistan","Hyderabad"});
          CountryStateCityTable.Rows.Add(new string[]{"Pakistan","Punjab","Karachi"});
          
          			
          this.CountryListBox.DataSource=new DataView(this.CountryStateCityTable).ToTable(true,"Country").DefaultView;
          this.CountryListBox.ValueMember="Country";
          this.CountryListBox.DisplayMember="Country";
          }
          }
          
          
          
          
          private void StateListBox_SelectedValueChanged(...)
          {
          	try
          	{
          		DataView view=new DataView(this.CountryStateCityTable);
          		view.RowFilter="Country='"+this.CountryListBox.SelectedItem.Text+"' AND State='"+this.StateListBox.SelectedItem.Text+"'";			
          		this.CityListBox.DataSource=viewToTable(true,"City").DefaultView;;
          		this.CityListBox.DisplayMember="City";
          		this.CityListBox.ValueMember="City";
          	}
          	catch(Exception exc)
          	{
                        Responce.Write(exc.Message);
          	}
          }
          
          private void CountryListBox_SelectedValueChanged(...)
          {
                 try
          	{
          	    DataView view=new DataView(this.CountryStateCityTable);
                      view.RowFilter="Country='"+this.CountryListBox.SelectedItem.Text+"'";		
          	    this.StateListBox.DataSource=view.ToTable(true,"State").DefaultView;
          	    this.StateListBox.DisplayMember="State";
          	    this.StateListBox.ValueMember="State";
          	}
          	catch(Exception exc)
          	{
                     Responce.Write(exc.Message);
          	}
          }

          - Balaji U

          Comment

          Working...