Hello dr_iton,
There is no need of this code :
if (!IsPostBack)
{
Paraqit_ddListKlasa();
}
In windows base application you need to write code in
form_load event.
public void Paraqit_ddListKlasa()
{
DataTable dt = new DataTable();
SqlConnection sqlConn = new SqlConnection(StringKoneksioni.Stringu);
sqlConn.Open();
string SQLstringu = "Select KlasaViti, ID_Klasa from KLASA ";
SqlCommand cmd = new SqlCommand(SQLstringu, sqlConn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
ddListKlasa.DataSource = dt;
ddListKlasa.DataTextField = "KlasaViti";
ddListKlasa.DataValueField = "ID_Klasa";
ddListKlasa.DataBind();
ddListKlasa.Items.Insert(0, new ListItem("--Zgjedh--", "0"));
sqlConn.Close();
}
call your method in form_load event like this :
Paraqit_ddListKlasa();
Other Idea:
-----------
1. Always try to create DAL (Data Access Layer) that you can use in WEB and WINDOWS FORM application as well.
Let me know if you have any further query.
Please, go through above link.
If its your answer, please mark as solution.
Best of luck for hunting solutions.
Thank you.
Regards,
Manoj Kalla