Click here to Skip to main content
15,509,982 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: set dropdownbox value which affect on other dropdown Pin
Gamzun8-Nov-09 21:47
Gamzun8-Nov-09 21:47 
AnswerRe: set dropdownbox value which affect on other dropdown Pin
deepseeindeepsy8-Nov-09 21:25
deepseeindeepsy8-Nov-09 21:25 
GeneralRe: set dropdownbox value which affect on other dropdown Pin
KIDYA8-Nov-09 21:39
KIDYA8-Nov-09 21:39 
GeneralRe: set dropdownbox value which affect on other dropdown Pin
deepseeindeepsy8-Nov-09 21:46
deepseeindeepsy8-Nov-09 21:46 
GeneralRe: set dropdownbox value which affect on other dropdown Pin
KIDYA8-Nov-09 21:55
KIDYA8-Nov-09 21:55 
GeneralRe: set dropdownbox value which affect on other dropdown Pin
deepseeindeepsy8-Nov-09 22:31
deepseeindeepsy8-Nov-09 22:31 
AnswerRe: set dropdownbox value which affect on other dropdown Pin
Nishant Singh9-Nov-09 0:25
Nishant Singh9-Nov-09 0:25 
AnswerRe: set dropdownbox value which affect on other dropdown Pin
April Fans9-Nov-09 22:20
April Fans9-Nov-09 22:20 
namespace WebApplicationDlh
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Db;
/// <summary>
/// Area
/// </summary>
public class Area : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.DropDownList ddlProvince;
protected System.Web.UI.WebControls.DropDownList ddlCity;
public string strProvince
{
get
{
return ddlProvince.SelectedItem.Value;
}
set
{
ddlProvince.SelectedItem.Value = value;
}
}
public string strCity
{
get
{
return ddlCity.SelectedItem.Value;
}
set
{
ddlCity.SelectedItem.Value = value;
}
}
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
ddlProvinceBind();
ddlCity.Items.Insert(0,"-City to choose-");
}
}
private void ddlProvinceBind()
{
Db.Area myArea = new Db.Area();
SqlDataReader dr = myArea.GetAllProvince();
if(dr.Read())
{
ddlProvince.DataSource = dr;
ddlProvince.DataTextField = "Province";
ddlProvince.DataValueField = "Province";
ddlProvince.DataBind();
ddlProvince.Items.Insert(0,"-Province to choose-");
}
}
#region Web
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
///
///
/// </summary>
private void InitializeComponent()
{
this.ddlProvince.SelectedIndexChanged += new System.EventHandler(this.ddlProvince_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void ddlProvince_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(ddlProvince.SelectedItem.Value == "-Province to choose-")
{
ddlCity.Items.Clear();
ddlCity.Items.Insert(ddlProvince.SelectedIndex,"-City to choose-");
}
else
{
Db.Area myArea = new Db.Area();
SqlDataReader dr = myArea.GetAllCityWhereProvince(ddlProvince.SelectedItem.Value);
if(dr.Read())
{
ddlCity.DataSource = dr;
ddlCity.DataTextField = "City";
ddlCity.DataValueField = "ID";
ddlCity.DataBind();
}
}
}
}
}

=============================================================〉
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace Db
{
/// <summary>
/// Area
/// </summary>
public class Area:Base
{
public Area()
{
//
// TODO:
//
}
public SqlDataReader GetAllProvince()
{
strSp = "Sp_Area_SelectAll";
drSelectAll(strSp);
return dr;
}
public SqlDataReader GetAllCityWhereProvince(string a)
{
conn = new SqlConnection(ConfigurationSettings.AppSettings["dsn"]);
cmd = new SqlCommand("Sp_Area_SelectAllWhereProvince",conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Province",SqlDbType.VarChar,50).Value = a.ToString();
conn.Open();
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
return dr;
}
}
}

=====================================================〉
if exists (select * from dbo.sysobjects where id = object_id(N’[dbo].[Sp_Area_SelectAll]’) and OBJECTPROPERTY(id, N’IsProcedure’) = 1)
drop procedure [dbo].[Sp_Area_SelectAll]
GO
if exists (select * from dbo.sysobjects where id = object_id(N’[dbo].[Sp_Area_SelectAllWhereProvince]’) and OBJECTPROPERTY(id, N’IsProcedure’) = 1)
drop procedure [dbo].[Sp_Area_SelectAllWhereProvince]
GO
if exists (select * from dbo.sysobjects where id = object_id(N’[dbo].[Area]’) and OBJECTPROPERTY(id, N’IsUserTable’) = 1)
drop table [dbo].[Area]
GO
CREATE TABLE [dbo].[Area] (
[ID] [int] NOT NULL ,
[Province] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[City] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
[其它] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE Sp_Area_SelectAll
AS
SELECT DISTINCT Province
FROM Area
ORDER BY Province
RETURN
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE Sp_Area_SelectAllWhereProvince
@Province varchar(50)
AS
SELECT Area.*
FROM Area
WHERE (Province = @Province)
RETURN
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
================================================〉
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration; namespace Db
{
/// <summary>
/// Base
/// </summary>
public class Base
{
public Base()
{
//
// TODO:
//
}
protected string con = ConfigurationSettings.AppSettings["dsn"];
protected SqlConnection conn;
protected SqlCommand cmd;
protected SqlDataReader dr;
protected string strSp;
protected SqlDataReader drSelectAll(string strSp)
{
conn = new SqlConnection(con);
cmd = new SqlCommand(strSp,conn);
cmd.CommandType = CommandType.StoredProcedure; conn.Open();
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
return dr;
}//SqlDataReader }
}
April

Comm100 - Leading Live Chat Software Provider


modified 27-May-14 21:55pm.

QuestionPDF File Not Read see my code. Pin
lrsalunkhe8-Nov-09 20:50
lrsalunkhe8-Nov-09 20:50 
AnswerRe: PDF File Not Read see my code. Pin
Gamzun8-Nov-09 21:17
Gamzun8-Nov-09 21:17 
GeneralRe: PDF File Not Read see my code. Pin
lrsalunkhe8-Nov-09 21:32
lrsalunkhe8-Nov-09 21:32 
GeneralRe: PDF File Not Read see my code. Pin
Gamzun8-Nov-09 21:45
Gamzun8-Nov-09 21:45 
QuestionHow to change the application's trust level? Pin
WinCrs8-Nov-09 20:44
WinCrs8-Nov-09 20:44 
AnswerRe: How to change the application's trust level? Pin
KIDYA8-Nov-09 22:02
KIDYA8-Nov-09 22:02 
AnswerRe: How to change the application's trust level? Pin
Abhishek Sur8-Nov-09 22:02
professionalAbhishek Sur8-Nov-09 22:02 
AnswerRe: How to change the application's trust level? Pin
dan!sh 8-Nov-09 22:06
professional dan!sh 8-Nov-09 22:06 
GeneralRe: How to change the application's trust level? Pin
Abhishek Sur8-Nov-09 22:09
professionalAbhishek Sur8-Nov-09 22:09 
GeneralRe: How to change the application's trust level? Pin
WinCrs8-Nov-09 22:28
WinCrs8-Nov-09 22:28 
GeneralRe: How to change the application's trust level? Pin
Abhishek Sur8-Nov-09 22:33
professionalAbhishek Sur8-Nov-09 22:33 
GeneralRe: How to change the application's trust level? Pin
WinCrs8-Nov-09 23:42
WinCrs8-Nov-09 23:42 
GeneralRe: How to change the application's trust level? Pin
Abhishek Sur9-Nov-09 0:05
professionalAbhishek Sur9-Nov-09 0:05 
GeneralRe: How to change the application's trust level? Pin
WinCrs9-Nov-09 0:23
WinCrs9-Nov-09 0:23 
QuestionPage refresh in Asp.net 3.5 Pin
angle578-Nov-09 19:55
angle578-Nov-09 19:55 
AnswerRe: Page refresh in Asp.net 3.5 Pin
Gamzun8-Nov-09 20:04
Gamzun8-Nov-09 20:04 
GeneralRe: Page refresh in Asp.net 3.5 Pin
angle578-Nov-09 20:07
angle578-Nov-09 20:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.