| |

VerySource

 Forgot password?
 Register
Search
Author: sonicliao

A little fun question!

[Copy link]

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-3 07:45:01
| Show all posts
Ok. Yes. That's it.
In this case, sometimes an error will be reported!
Report an error called repeated binding data source
Therefore, if you bind in the interface and bind in the code, you can only write one of them, not both of them.
Reply

Use magic Report

0

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-7-6 19:30:01
| Show all posts
sonicliao

I can't figure out why program binding and design state binding are different.

---------------------------

I did not want to understand.
These two methods should be implemented if the data source of the non-DataSource control is bound in the background
GridView1_RowEditing, GridView1_RowUpdating
But now the DataSource control data source is bound, it looks like it should be the same,
I think something is wrong there, it should be relatively simple.
Hope that the master will give advice.
Reply

Use magic Report

0

Threads

10

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-7-7 14:30:01
| Show all posts
Bind again
Reply

Use magic Report

0

Threads

10

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-7-7 14:45:01
| Show all posts
support
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-7 15:15:01
| Show all posts
Mark
Reply

Use magic Report

0

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-7-14 23:30:01
| Show all posts
I have found the answer:

protected void Page_Init(object sender, EventArgs e)
    {
        this.GridView1.DataSourceID = "AccessDataSource1";
    }

Specified here, but DataSource cannot be used, because other controls cannot be accessed at this time.
Reply

Use magic Report

2

Threads

11

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

 Author| Post time: 2020-7-17 12:45:01
| Show all posts
mgcfox.
Thank you! really. But there is still a problem.
I modified Select Updata etc. dynamically while the program was running. But Updata seems to have no effect. Because when init is bound back to the original sqldatasource1. Do you have another way?
Reply

Use magic Report

0

Threads

8

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-7-17 16:00:01
| Show all posts
GridView1. DataSource = SqlDataSource1;
GridView1. DataBind();
This way of writing is not to bind GridView1 to SqlDataSource1 at all, but only to bind the data obtained after SELECTing SqlDataSource1, and the UPDATE/INSERT/DELETE method is not bound at all.

The correct equivalent:
GridView1.DataSourceID = "SqlDataSource1";
// No need to execute DataBind();
Reply

Use magic Report

0

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-7-22 08:30:01
| Show all posts
sonicliao
I dynamically modified Select Updata while the program was running. But Updata seems to have no effect. Because it is bound back to the original sqldatasource1 during init. Do you have any other way?

------------------------
I have tested it here, and it is exactly the same as stated in the control.
If you cannot update with Update, see if DataKeyNames is not specified?
When I tested, I dragged the controls to handle everything, then deleted the DataSourceID property of the GridView in the page, and then specified it in the cs file.
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 Invalid IP Address

Post time: 2020-7-24 18:30:01
| Show all posts
To be redefined. .
In 05 there are OnRowCancelingEdit, OnRowUpdating, and so on. .
Go and see the help of this, I tried it in your case. . . I don't want to write the edited code myself. . . But don't want to use the wizard to complete the binding. . .
Finally, write the code honestly. . .
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