Specified cast is not valid. (hmmm, men hvad er forkert?)
Hejsa,Således gør jeg:
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dbReader As OleDb.OleDbDataReader
Dim cmpGroup As New cmpGroup()
Dim Item As RepeaterItem
For Each Item In Repeater1.Items
Dim HiddenGroupID As String = CType(Item.FindControl("TextBox1"), TextBox).Text
Dim HiddenCategoryID As String = CType(Item.FindControl("TextBox2"), TextBox).Text
Dim PointValue As DropDownList = CType(Item.FindControl("DropDownList1"), DropDownList)
cmpGroup.updateGroupCategoryRights(CInt(HiddenCategoryID), CInt(HiddenGroupID), CInt(PointValue.SelectedItem.Value), 2)
bodyMain.Attributes.Add("onload", "window.close();")
Next Item
End Sub
Jeg får denne her fejl:
Server Error in '/cmsLight' Application.
--------------------------------------------------------------------------------
Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Line 52: Dim cmpGroup As New cmpGroup()
Line 53: Dim Item As RepeaterItem
Line 54: For Each Item In Repeater1.Items
Line 55: Dim HiddenGroupID As String = CType(Item.FindControl("TextBox1"), TextBox).Text
Line 56: Dim HiddenCategoryID As String = CType(Item.FindControl("TextBox2"), TextBox).Text
Source File: C:\Inetpub\wwwroot\cmsLight\ui2\GroupRightsByItemID.aspx.vb Line: 54
Stack Trace:
[InvalidCastException: Specified cast is not valid.]
cmsLight.GroupRightsByItemID1.Button1_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\cmsLight\ui2\GroupRightsByItemID.aspx.vb:54
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
På mdsn gør de også således som jeg gør: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsrepeateritemclasstopic.asp
På forhån taxi!
Lauge
