adding data

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...
 
S

Simon Gorski

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.
 
S

Selen

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.
 
S

Simon Gorski

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top