| |

VerySource

 Forgot password?
 Register
Search
View: 675|Reply: 2

Everyone, please help!

[Copy link]

2

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-17 17:00:01
| Show all posts |Read mode
Server error in "/ WedUser" application.
-------------------------------------------------- ------------------------------

The specified conversion is invalid.
Explanation: An unhandled exception occurred during the execution of the current web request. Check the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: The specified conversion is invalid.

Source error:


Line 31: </ asp: TemplateField>
Line 32: <asp: TemplateField HeaderText = "is the administrator"> <ItemTemplate>
Line 33: <asp: CheckBox ID = "IsAdminCheck" Enabled = "false" runat = "server" Checked = '<% # (bool) DataBinder.Eval (Container.DataItem, "IsAdmin")%>' />
Line 34: </ ItemTemplate>
Line 35: </ asp: TemplateField>

Add this sentence: Checked = '<% # (bool) DataBinder.Eval (Container.DataItem, "IsAdmin")%>' then the above error appears!
Reply

Use magic Report

0

Threads

73

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-1-24 03:00:01
| Show all posts
Checked = '<% # (bool) DataBinder.Eval (Container.DataItem, "IsAdmin")%>'
Change to
Checked = '<% # checkAdmin (DataBinder.Eval (Container.DataItem, "IsAdmin"))%>'

Add a function in the background:
public bool checkAdmin (object fg) {
bool returnValue;
try {
    returnValue = Convert.ToBool (fg);
  }
catch (Exception) {
  returnValue = false;
}
return returnValue;
}
Reply

Use magic Report

0

Threads

73

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-1-24 05:54:01
| Show all posts
The above is wrong, it is Convert.ToBoolean (fg);
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