| |

VerySource

 Forgot password?
 Register
Search
Author: reuental

Depressed. . PostBack issues

[Copy link]

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-30 08:15:01
| Show all posts
if(!IsPostBack)
{}
Change to
if(!Page.IsPostBack)
{}
Reply

Use magic Report

0

Threads

15

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-7-30 09:00:01
| Show all posts
The code in (!IsPostBack) is not executed when returning
There should be something else.
Reply

Use magic Report

0

Threads

110

Posts

63.00

Credits

Newbie

Rank: 1

Credits
63.00

 China

Post time: 2020-7-30 10:00:01
| Show all posts
What does the original poster mean?

Does it mean that after changing the item, execute this code again?

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();


If so, why use if (!IsPostBack)?
!IsPostBack means executed when the page is loaded for the first time...

Try removing this sentence...

Or I misunderstood what the original poster meant?
Reply

Use magic Report

2

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 Australia

 Author| Post time: 2020-8-1 23:30:01
| Show all posts
When my page is loaded, a LISTBOX project is generated through the database,
After executing the LISTBOX_INDEXCHANGE process, the items in the LISTbox are actually added again
However, the program did not perform any repeated addition process.
I just copied a copy of the items in the LISTBOX inexplicably
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-2 03:00:01
| Show all posts
Try to disable viewstate
Reply

Use magic Report

0

Threads

110

Posts

63.00

Credits

Newbie

Rank: 1

Credits
63.00

 China

Post time: 2020-8-2 09:45:01
| Show all posts
Dizzy, I read the wrong question...

TO: When my page is loaded, the LISTBOX project is generated through the database,
After executing the LISTBOX_INDEXCHANGE process, the items in the LISTbox are actually added again
However, the program did not perform any repeated addition process.
I just copied a copy of the items in the LISTBOX inexplicably


It's really strange...

Or change your mind..

Don't add it like this, directly bind the data in the database..

When updating, write back to the database first, and then rebind.
Reply

Use magic Report

2

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 Australia

 Author| Post time: 2020-8-5 10:00:01
| Show all posts
solved. .
I deleted the page and wrote it once. . .
normal now. . .

Well, it comes down to a foreign spirit event
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