-
Notifications
You must be signed in to change notification settings - Fork 0
/
Kategoriler.aspx.cs
50 lines (41 loc) · 1.4 KB
/
Kategoriler.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class Kategoriler : System.Web.UI.Page
{
sqlsinif bgl = new sqlsinif();
string id = "";
string islem = "";
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack == false)
{
id = Request.QueryString["Kategoriid"];
islem = Request.QueryString["islem"];
}
SqlCommand komut = new SqlCommand("Select * From Tbl_Kategoriler", bgl.baglanti());
SqlDataReader dr = komut.ExecuteReader();
DataList1.DataSource = dr;
DataList1.DataBind();
//SİLME İŞLEMİ
if (islem == "sil")
{
SqlCommand komutsil = new SqlCommand("delete from tbl_kategoriler where kategoriid=@p1", bgl.baglanti());
komutsil.Parameters.AddWithValue("@p1", id);
komutsil.ExecuteNonQuery();
bgl.baglanti().Close();
}
}
protected void BtnEkle_Click(object sender, EventArgs e)
{
SqlCommand komut = new SqlCommand("insert into Tbl_Kategoriler (KategoriAd) values (@p1)", bgl.baglanti());
komut.Parameters.AddWithValue("@p1", TextBox1.Text);
komut.ExecuteNonQuery();
bgl.baglanti().Close();
TextBox1.Text = string.Empty;
}
}