0% found this document useful (0 votes)
3 views2 pages

ASP Sayfa1

The document is a C# ASP.NET code for a web page that retrieves and displays continents and countries from a database. Upon loading, it populates a dropdown list with continents and allows users to select one to fetch corresponding countries. It also includes a button for user login redirection to another page.

Uploaded by

m0nst3rs737
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

ASP Sayfa1

The document is a C# ASP.NET code for a web page that retrieves and displays continents and countries from a database. Upon loading, it populates a dropdown list with continents and allows users to select one to fetch corresponding countries. It also includes a button for user login redirection to another page.

Uploaded by

m0nst3rs737
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.ServiceModel.Channels;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class Sayfa1BK : System.Web.UI.Page


{
public string baglantiMetni =
ConfigurationManager.ConnectionStrings["veritabaniminAdresi"].ToString();

protected void Page_Load(object sender, EventArgs e)


{
if(!IsPostBack)
{
try
{
butUlkeGetir.Text = "Ülkeleri getir..";
butUlkeGetir.Visible = false;
gViewUlkeler.Visible = false;

lblKitalar.Text = "Kıtalar";
lBtnGirisFormu.Text = "Kullanıcı Girişi";

SqlConnection sqlConnection = new SqlConnection(baglantiMetni);


SqlCommand sqlKomutuKitalar = new SqlCommand()
{
Connection = sqlConnection,
CommandType = CommandType.StoredProcedure,
CommandText = "SP_KitaGetirBK"
};

SqlDataReader veriOkuyucu;

sqlConnection.Open();

veriOkuyucu = sqlKomutuKitalar.ExecuteReader();

while(veriOkuyucu.Read())
{
ddListKitalar.Items.Add(veriOkuyucu[0].ToString());
}

sqlConnection.Close();
}
catch
{
Response.Redirect("Sayfa1BK.aspx");
}
}
}

protected void ddListKitalar_SelectedIndexChanged(object sender, EventArgs


e)
{
butUlkeGetir.Visible = true;
}

protected void butUlkeGetir_Click(object sender, EventArgs e)


{
string secilenKita = ddListKitalar.SelectedValue;
gViewUlkeler.Visible = true;

SqlConnection sqlConnection = new SqlConnection(baglantiMetni);


SqlCommand sqlKomutuUlkeler = new SqlCommand()
{
Connection = sqlConnection,
CommandType = CommandType.StoredProcedure,
CommandText = "SP_UlkeleriGetirBK"
};
SqlParameter pKitaAdi = new SqlParameter("@pKitaAdi",
SqlDbType.VarChar);
pKitaAdi.Value = secilenKita;
sqlKomutuUlkeler.Parameters.Add(pKitaAdi);

//SqlDataAdapter
DataTable WebSunucusuVeriKumesi = new DataTable();
SqlDataAdapter veriTasiyici = new SqlDataAdapter(sqlKomutuUlkeler);

veriTasiyici.Fill(WebSunucusuVeriKumesi);

gViewUlkeler.DataSource = WebSunucusuVeriKumesi;
gViewUlkeler.DataBind(); //gridview kaynagındaki verinin grid view
aracılıgı ile ekrana yansıtılması

protected void lBtnGirisFormu_Click(object sender, EventArgs e)


{
Response.Redirect("Sayfa2BK.aspx");
}
}

You might also like