adding data

  • Thread starter Thread starter Selen
  • Start date Start date
S

Selen

Hello,
I add my data from sqlserver to dropdownlist on formload.I wanted it doesnt
load data every time on form load.I made if session is null then load if
session isnt null dont load.I add to sqlserver a new data ans I make session
is null.But in dropdownlist I coudnt see my new data.I use below code for
adding.I make logic error. Is Using Session logic true? or I have to refresh
sql data if so how can I do this...
SqlConnection conn=new SqlConnection ();

conn.ConnectionString
="server=(local)\\sql2000;database=db_Kalite_Data;uid=sa;pwd=antalya";

SqlCommand cmd=new SqlCommand ();

cmd.Connection =conn;

string str="insert ........................";

cmd.CommandText =str;

conn.Open ();

cmd.ExecuteNonQuery ();

conn.Close ();

Thanks...
 
Hello Selen,
Selen said:
Hello,
I add my data from sqlserver to dropdownlist on formload.I wanted it doesnt
load data every time on form load.I made if session is null then load if
session isnt null dont load.I add to sqlserver a new data ans I make session
is null.But in dropdownlist I coudnt see my new data.I use below code for
adding.I make logic error. Is Using Session logic true? or I have to refresh
sql data if so how can I do this...
SqlConnection conn=new SqlConnection ();

conn.ConnectionString
="server=(local)\\sql2000;database=db_Kalite_Data;uid=sa;pwd=antalya";

SqlCommand cmd=new SqlCommand ();

cmd.Connection =conn;

string str="insert ........................";

cmd.CommandText =str;

conn.Open ();

cmd.ExecuteNonQuery ();

conn.Close ();

Thanks...

I think the problem is, that you must re-bind the dropdownlist after
refreshing the data!

mfg simon g.
 
sorry What you mean re-bind??

Thank you...

iletide þunu yazdý said:
Hello Selen,


I think the problem is, that you must re-bind the dropdownlist after
refreshing the data!

mfg simon g.
 
Hello Selen,
Selen said:
sorry What you mean re-bind??

Thank you...

DropDownList myList = new DropDownList();

myList.Add("newItem1");

myList.Add("newItem2");

myList.DataBind(); <--

After you refreshed your data, you have to make a re-bind -->
myList.DataBind();

mfg simon g.
 
Back
Top