protected
void
Page_Load(
object
sender, EventArgs e)
{
try
{
if
(!Page.IsPostBack)
{
string
connectionString = ConfigurationManager.ConnectionStrings[
"VeriConnectionString"
].ConnectionString;
SqlConnection conn =
new
SqlConnection(connectionString);
conn.Open();
SqlCommand cmd =
new
SqlCommand(
"SELECT id, Kategori FROM Kategori"
, conn);
cmd.CommandType = CommandType.Text;
SqlDataAdapter da =
new
SqlDataAdapter(cmd);
DataTable dt =
new
DataTable();
da.Fill(dt);
DropDownListKategori.DataTextField =
"Kategori"
;
DropDownListKategori.DataValueField =
"id"
;
DropDownListKategori.DataSource = dt;
DropDownListKategori.DataBind();
DropDownListKategori.Items.Insert(0,
new
ListItem(
"– Seçiniz –"
,
"0"
));
conn.Close();
}
}
catch
(Exception ex)
{
}
}
protected
void
DropDownListKategori_SelectedIndexChanged(
object
sender, EventArgs e)
{
try
{
string
connectionString = ConfigurationManager.ConnectionStrings[
"VeriConnectionString"
].ConnectionString;
SqlConnection conn =
new
SqlConnection(connectionString);
conn.Open();
SqlCommand cmd =
new
SqlCommand(
"SELECT id, AltKategori FROM AltKategori WHERE KategoriId = @KategoriId"
, conn);
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add(
new
SqlParameter(
"@KategoriId"
, Convert.ToInt32(DropDownListKategori.SelectedValue))
);
SqlDataAdapter da =
new
SqlDataAdapter(cmd);
DataTable dt =
new
DataTable();
da.Fill(dt);
DropDownListAltKategori.DataTextField =
"AltKategori"
;
DropDownListAltKategori.DataValueField =
"id"
;
DropDownListAltKategori.DataSource = dt;
DropDownListAltKategori.DataBind();
conn.Close();
}
catch
(Exception exp)
{
}
}