| |

VerySource

 Forgot password?
 Register
Search
View: 1715|Reply: 16

Depressed. . PostBack issues

[Copy link]

2

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 Australia

Post time: 2020-3-9 18:00:01
| Show all posts |Read mode
if (! IsPostBack)
{
Ranch
string strConn = "Data Source = cnshangh601p; uid = accpac; pwd = accpac; Initial Catalog = ELSH";
SqlConnection sqlcn = new SqlConnection (strConn);
sqlcn.Open ();
SqlCommand selectCmd2 = new SqlCommand ("Select * From ReportUser where UserType = 2", sqlcn);
SqlDataReader dr2;
dr2 = selectCmd2.ExecuteReader ();
while (dr2.Read ())
{
UserList.Items.Add (new ListItem (dr2 ["UserName"]. ToString (), dr2 ["LogName"]. ToString ()));
}
dr2.Close ();
sqlcn.Close ();

The list items in my program are directly formed using the above code,
Control specified autopostback
I am good at executing the program when changing the list options,
result. . . .
Each time the option is changed, the list is repeated with the results of the above procedure. . That's the part of the while statement. . No matter how you change the program. . .
Ranch
}
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-5-31 11:30:01
| Show all posts
UserList.Items.Clear ()

// Clear options before adding
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 China

Post time: 2020-5-31 14:00:01
| Show all posts
Before while ("if (! IsPostBack) {" after) clear UserList
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 Great Britain

Post time: 2020-5-31 23:15:01
| Show all posts
dr2 = selectCmd2.ExecuteReader ();
UserList.Items.Clear (); // Newly added

while (dr2.Read ())
{
UserList.Items.Add (new ListItem (dr2 ["UserName"]. ToString (), dr2 ["LogName"]. ToString ()));
}
Reply

Use magic Report

2

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 Australia

 Author| Post time: 2020-6-1 23:00:01
| Show all posts
Added is useless

It doesn't matter how you add it. Like a bug
Only execute the while statement, and ignore all others
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 France

Post time: 2020-6-2 11:00:01
| Show all posts
impossible
Reply

Use magic Report

2

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-6-4 17:00:01
| Show all posts
I also think it's impossible, and that's what happened now. . .
I followed it. After postback, no statement was executed at all,
The control itself has more content.
Reply

Use magic Report

0

Threads

48

Posts

30.00

Credits

Newbie

Rank: 1

Credits
30.00

 China

Post time: 2020-7-2 08:30:01
| Show all posts
Code elsewhere
Reply

Use magic Report

0

Threads

13

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-7-29 13:30:01
| Show all posts
Does lz add code to the code after double-clicking UserList?
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Invalid IP Address

Post time: 2020-7-29 23:15:01
| Show all posts
It may be executed twice, that is, the event is triggered twice!?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list