janjuama84
asked on
Convertion from VB to C#
Can somebody please convert following code to C#?
''' <summary>
''' This page allows for classes to have seats deducted from it
''' </summary>
''' <remarks></remarks>
Partial Class _Default
  Inherits System.Web.UI.Page
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    ' if first load then setup classes
    If Not Page.IsPostBack Then
      InitialiseClasses()
      UpdateLabels()
    End If
  End Sub
  ''' <summary>
  ''' Initialises the Class Arrays based on parameters passed
  ''' </summary>
  ''' <param name="ClassSizes">The Size of the Classes</param>
  ''' <param name="AmountofClasses">The Amount of Classes to Create</param>
  ''' <remarks></remarks>
  Private Sub InitialiseClasses(Optional ByVal ClassSizes As Integer = 15, Optional ByVal AmountofClasses As Integer = 3)
    Dim TheClasses As New ArrayList()
    Dim i As Integer
    ' For the Amount of Classes Specified
    For i = 1 To AmountofClasses
      ' Add an integer of size ClassSizes to the ArrayList
      TheClasses.Add(ClassSizes)
    Next
    ' Add the Classes Arraylist to the Session
    Session("Classes") = TheClasses
    ' Create an Arraylist of the size of ClassSizes and bind it to the Radio List
    radSeatsAvailable.DataSour ce = PopulateArrayList(ClassSiz es)
    radSeatsAvailable.DataBind ()
  End Sub
  ''' <summary>
  ''' Creates and returns an array list of 1 to the specified size
  ''' </summary>
  ''' <param name="ArrayListLength">The Size of the ArrayList</param>
  ''' <returns>ArrayList of integers from 1 to ArrayListLength</returns>
  ''' <remarks></remarks>
  Private Function PopulateArrayList(ByVal ArrayListLength As Integer) As ArrayList
    Dim myarray As New ArrayList
    Dim i As Integer
    ' For the size of the arraylist
    For i = 1 To ArrayListLength
      ' Add an integer of the value i
      myarray.Add(i)
    Next
    Return myarray
  End Function
  ''' <summary>
  ''' Resets the radiolist when the dropdownlist with classes is changed
  ''' </summary>
  ''' <param name="sender"></param>
  ''' <param name="e"></param>
  ''' <remarks></remarks>
  Protected Sub ddlClass_SelectedIndexChan ged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlClass.SelectedIndexChan ged
    ' ReBind the radiolist based on the amount of seats left in the class
    radSeatsAvailable.DataSour ce = PopulateArrayList(Session( "classes") .Item(ddlC lass.Selec tedIndex). ToString)
    radSeatsAvailable.DataBind ()
    UpdateLabels()
  End Sub
  ''' <summary>
  ''' On Click update the amount of seats left in the class
  ''' </summary>
  ''' <param name="sender"></param>
  ''' <param name="e"></param>
  ''' <remarks></remarks>
  Protected Sub btnRegister_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRegister.Click
    ' Deduct the amount of seats based on the radio button selected
    Session("classes").Item(dd lClass.Sel ectedIndex ) = Session("classes").Item(dd lClass.Sel ectedIndex ) - radSeatsAvailable.Selected Index - 1
    ' Bind the new amount of seats left
    radSeatsAvailable.DataSour ce = PopulateArrayList(Session( "classes") .Item(ddlC lass.Selec tedIndex). ToString)
    radSeatsAvailable.DataBind ()
    UpdateLabels()
  End Sub
  ''' <summary>
  ''' Updates the labels for user feedback
  ''' </summary>
  ''' <remarks></remarks>
  Private Sub UpdateLabels()
    lblClass1.Text = Session("classes").Item(0) .ToString
    lblClass2.Text = Session("classes").Item(1) .ToString
    lblClass3.Text = Session("classes").Item(2) .ToString
  End Sub
End Class
''' <summary>
''' This page allows for classes to have seats deducted from it
''' </summary>
''' <remarks></remarks>
Partial Class _Default
  Inherits System.Web.UI.Page
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    ' if first load then setup classes
    If Not Page.IsPostBack Then
      InitialiseClasses()
      UpdateLabels()
    End If
  End Sub
  ''' <summary>
  ''' Initialises the Class Arrays based on parameters passed
  ''' </summary>
  ''' <param name="ClassSizes">The Size of the Classes</param>
  ''' <param name="AmountofClasses">The
  ''' <remarks></remarks>
  Private Sub InitialiseClasses(Optional
    Dim TheClasses As New ArrayList()
    Dim i As Integer
    ' For the Amount of Classes Specified
    For i = 1 To AmountofClasses
      ' Add an integer of size ClassSizes to the ArrayList
      TheClasses.Add(ClassSizes)
    Next
    ' Add the Classes Arraylist to the Session
    Session("Classes") = TheClasses
    ' Create an Arraylist of the size of ClassSizes and bind it to the Radio List
    radSeatsAvailable.DataSour
    radSeatsAvailable.DataBind
  End Sub
  ''' <summary>
  ''' Creates and returns an array list of 1 to the specified size
  ''' </summary>
  ''' <param name="ArrayListLength">The
  ''' <returns>ArrayList of integers from 1 to ArrayListLength</returns>
  ''' <remarks></remarks>
  Private Function PopulateArrayList(ByVal ArrayListLength As Integer) As ArrayList
    Dim myarray As New ArrayList
    Dim i As Integer
    ' For the size of the arraylist
    For i = 1 To ArrayListLength
      ' Add an integer of the value i
      myarray.Add(i)
    Next
    Return myarray
  End Function
  ''' <summary>
  ''' Resets the radiolist when the dropdownlist with classes is changed
  ''' </summary>
  ''' <param name="sender"></param>
  ''' <param name="e"></param>
  ''' <remarks></remarks>
  Protected Sub ddlClass_SelectedIndexChan
    ' ReBind the radiolist based on the amount of seats left in the class
    radSeatsAvailable.DataSour
    radSeatsAvailable.DataBind
    UpdateLabels()
  End Sub
  ''' <summary>
  ''' On Click update the amount of seats left in the class
  ''' </summary>
  ''' <param name="sender"></param>
  ''' <param name="e"></param>
  ''' <remarks></remarks>
  Protected Sub btnRegister_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRegister.Click
    ' Deduct the amount of seats based on the radio button selected
    Session("classes").Item(dd
    ' Bind the new amount of seats left
    radSeatsAvailable.DataSour
    radSeatsAvailable.DataBind
    UpdateLabels()
  End Sub
  ''' <summary>
  ''' Updates the labels for user feedback
  ''' </summary>
  ''' <remarks></remarks>
  Private Sub UpdateLabels()
    lblClass1.Text = Session("classes").Item(0)
    lblClass2.Text = Session("classes").Item(1)
    lblClass3.Text = Session("classes").Item(2)
  End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
what to do with
    // Warning!!! Optional parameters not supported
    // Warning!!! Optional parameters not supported
how to convert those?
    // Warning!!! Optional parameters not supported
    // Warning!!! Optional parameters not supported
how to convert those?
Optional parameters are not supported in C#. Â TO get the same behavior, you need to create mutliple methods. Â For example.
if you have a sub in vb called dosomething with two parameters and one is optional, in c# you would do
public void dosomething(int MyParm1){
//your code
}
public void dosomething(int MyParm1, int MyParm2){
//your code to use when both paramters are needed.
}
if you have a sub in vb called dosomething with two parameters and one is optional, in c# you would do
public void dosomething(int MyParm1){
//your code
}
public void dosomething(int MyParm1, int MyParm2){
//your code to use when both paramters are needed.
}
ASKER
this line
 Private Sub InitialiseClasses(Optional ByVal ClassSizes As Integer = 15, Optional ByVal AmountofClasses As Integer = 3)
is converted into this
private void InitialiseClasses(int ClassSizes, void =, void 15, int AmountofClasses, void =, void 3) {
doesn't look right
 Private Sub InitialiseClasses(Optional
is converted into this
private void InitialiseClasses(int ClassSizes, void =, void 15, int AmountofClasses, void =, void 3) {
doesn't look right
ASKER
Can you help me convert this properly....
  ''' <summary>
  ''' Resets the radiolist when the dropdownlist with classes is changed
  ''' </summary>
  ''' <param name="sender"></param>
  ''' <param name="e"></param>
  ''' <remarks></remarks>
  Protected Sub ddlClass_SelectedIndexChan ged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlClass.SelectedIndexChan ged
    ' ReBind the radiolist based on the amount of seats left in the class
    radSeatsAvailable.DataSour ce = PopulateArrayList(Session( "classes") .Item(ddlC lass.Selec tedIndex). ToString)
    radSeatsAvailable.DataBind ()
    UpdateLabels()
  End Sub
  ''' <summary>
  ''' Resets the radiolist when the dropdownlist with classes is changed
  ''' </summary>
  ''' <param name="sender"></param>
  ''' <param name="e"></param>
  ''' <remarks></remarks>
  Protected Sub ddlClass_SelectedIndexChan
    ' ReBind the radiolist based on the amount of seats left in the class
    radSeatsAvailable.DataSour
    radSeatsAvailable.DataBind
    UpdateLabels()
  End Sub
Automated tools can't do it all! Â Try just changing it to
private void InitialiseClasses(int ClassSizes, int AmountofClasses) {
private void InitialiseClasses(int ClassSizes, int AmountofClasses) {
  /// <summary>
  ///  Resets the radiolist when the dropdownlist with classes is changed
  ///  </summary>
  ///  <param name="sender"></param>
  ///  <param name="e"></param>
  ///  <remarks></remarks>
  protected void ddlClass_SelectedIndexChan ged(object sender, System.EventArgs e) {
    //  ReBind the radiolist based on the amount of seats left in the class
    radSeatsAvailable.DataSour ce = PopulateArrayList(Session( "classes") .Item[ddlC lass.Selec tedIndex]. ToString);
    radSeatsAvailable.DataBind ();
    UpdateLabels();
  }
  ///  Resets the radiolist when the dropdownlist with classes is changed
  ///  </summary>
  ///  <param name="sender"></param>
  ///  <param name="e"></param>
  ///  <remarks></remarks>
  protected void ddlClass_SelectedIndexChan
    //  ReBind the radiolist based on the amount of seats left in the class
    radSeatsAvailable.DataSour
    radSeatsAvailable.DataBind
    UpdateLabels();
  }
In the IDE, highlight the ddlClass object and in the SelectedIndexChanged event, enter ddlClass_SelectedIndexChan ged as the handler. Â Or to manually do it, you could put this in your page load
ddlClass.SelectedIndexChan ged += ddlClass_SelectedIndexChan ged(object sender, System.EventArgs e);
ddlClass.SelectedIndexChan
ASKER
this is the code I have right now
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls. WebParts;
using System.Web.UI.HtmlControls ;
public partial class Labs_lab2 : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e) {
    //  if first load then setup classes
    if (!Page.IsPostBack) {
      InitialiseClasses();
      UpdateLabels();
    }
}
  private void InitialiseClasses(int ClassSizes, int AmountofClasse) {
    ClassSizes = 15;
    AmountofClasse = 3;
    ArrayList TheClasses = new ArrayList();
    // Warning!!! Optional parameters not supported
    // Warning!!! Optional parameters not supported
    int i;
    //  For the Amount of Classes Specified
    for (i = 1; (i <= AmountofClasses); i++) {
      //  Add an integer of size ClassSizes to the ArrayList
      TheClasses.Add(ClassSizes) ;
    }
    //  Add the Classes Arraylist to the Session
    Session("Classes") = TheClasses;
    //  Create an Arraylist of the size of ClassSizes and bind it to the Radio List
    radSeatsAvailable.DataSour ce = PopulateArrayList(ClassSiz es);
    radSeatsAvailable.DataBind ();
  }
  private ArrayList PopulateArrayList(int ArrayListLength) {
    ArrayList myarray = new ArrayList();
    int i;
    //  For the size of the arraylist
    for (i = 1; (i <= ArrayListLength); i++) {
      //  Add an integer of the value i
      myarray.Add(i);
    }
    return myarray;
  }
 Â
  protected void ddlClass_SelectedIndexChan ged(object sender, System.EventArgs e) {
    //  ReBind the radiolist based on the amount of seats left in the class
    radSeatsAvailable.DataSour ce = PopulateArrayList(Session( "classes") .Item[ddlC lass.Selec tedIndex]. ToString);
    radSeatsAvailable.DataBind ();
    UpdateLabels();
  }
 Â
  protected void btnPurchase_Click(object sender, System.EventArgs e) {
    //  Deduct the amount of seats based on the radio button selected
    Session("classes").Item[dd lClass.Sel ectedIndex ] = (Session("classes").Item[d dlClass.Se lectedInde x]
          - (radSeatsAvailable.Selecte dIndex - 1));
    //  Bind the new amount of seats left
    radSeatsAvailable.DataSour ce = PopulateArrayList(Session( "classes") .Item[ddlC lass.Selec tedIndex]. ToString);
    radSeatsAvailable.DataBind ();
    UpdateLabels();
  }
 Â
  private void UpdateLabels() {
    lblClass1.Text = Session("classes").Item[0] .ToString;
    lblClass2.Text = Session("classes").Item[1] .ToString;
    lblClass3.Text = Session("classes").Item[2] .ToString;
  }
}
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.
using System.Web.UI.HtmlControls
public partial class Labs_lab2 : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e) {
    //  if first load then setup classes
    if (!Page.IsPostBack) {
      InitialiseClasses();
      UpdateLabels();
    }
}
  private void InitialiseClasses(int ClassSizes, int AmountofClasse) {
    ClassSizes = 15;
    AmountofClasse = 3;
    ArrayList TheClasses = new ArrayList();
    // Warning!!! Optional parameters not supported
    // Warning!!! Optional parameters not supported
    int i;
    //  For the Amount of Classes Specified
    for (i = 1; (i <= AmountofClasses); i++) {
      //  Add an integer of size ClassSizes to the ArrayList
      TheClasses.Add(ClassSizes)
    }
    //  Add the Classes Arraylist to the Session
    Session("Classes") = TheClasses;
    //  Create an Arraylist of the size of ClassSizes and bind it to the Radio List
    radSeatsAvailable.DataSour
    radSeatsAvailable.DataBind
  }
  private ArrayList PopulateArrayList(int ArrayListLength) {
    ArrayList myarray = new ArrayList();
    int i;
    //  For the size of the arraylist
    for (i = 1; (i <= ArrayListLength); i++) {
      //  Add an integer of the value i
      myarray.Add(i);
    }
    return myarray;
  }
 Â
  protected void ddlClass_SelectedIndexChan
    //  ReBind the radiolist based on the amount of seats left in the class
    radSeatsAvailable.DataSour
    radSeatsAvailable.DataBind
    UpdateLabels();
  }
 Â
  protected void btnPurchase_Click(object sender, System.EventArgs e) {
    //  Deduct the amount of seats based on the radio button selected
    Session("classes").Item[dd
          - (radSeatsAvailable.Selecte
    //  Bind the new amount of seats left
    radSeatsAvailable.DataSour
    radSeatsAvailable.DataBind
    UpdateLabels();
  }
 Â
  private void UpdateLabels() {
    lblClass1.Text = Session("classes").Item[0]
    lblClass2.Text = Session("classes").Item[1]
    lblClass3.Text = Session("classes").Item[2]
  }
}
Are you getting errors?
ASKER
yes here is it
Compiler Error Message: CS1501: No overload for method 'InitialiseClasses' takes '0' arguments
Source Error:
Â
Line 15: Â Â Â Â // Â if first load then setup classes
Line 16: Â Â Â Â if (!Page.IsPostBack) {
Line 17: Â Â Â Â Â Â InitialiseClasses();
Line 18: Â Â Â Â Â Â UpdateLabels();
Line 19: Â Â Â Â }
Â
Compiler Error Message: CS1501: No overload for method 'InitialiseClasses' takes '0' arguments
Source Error:
Â
Line 15: Â Â Â Â // Â if first load then setup classes
Line 16: Â Â Â Â if (!Page.IsPostBack) {
Line 17: Â Â Â Â Â Â InitialiseClasses();
Line 18: Â Â Â Â Â Â UpdateLabels();
Line 19: Â Â Â Â }
Â
Ok....so your call to initialiseClasses was not using either of the optional paramters in VB, so you new method should be this. Â Replace your existing IntialiseClasses method with these 2 methods.
 private void InitialiseClasses() {
    ClassSizes = 15;
    AmountofClasse = 3;
    ArrayList TheClasses = new ArrayList();
    // Warning!!! Optional parameters not supported
    // Warning!!! Optional parameters not supported
    int i;
    //  For the Amount of Classes Specified
    for (i = 1; (i <= AmountofClasses); i++) {
      //  Add an integer of size ClassSizes to the ArrayList
      TheClasses.Add(ClassSizes) ;
    }
    //  Add the Classes Arraylist to the Session
    Session("Classes") = TheClasses;
    //  Create an Arraylist of the size of ClassSizes and bind it to the Radio List
    radSeatsAvailable.DataSour ce = PopulateArrayList(ClassSiz es);
    radSeatsAvailable.DataBind ();
  }
 private void InitialiseClasses(int ClassSizes, int AmountofClasse) {
    ArrayList TheClasses = new ArrayList();
    int i;
    //  For the Amount of Classes Specified
    for (i = 1; (i <= AmountofClasses); i++) {
      //  Add an integer of size ClassSizes to the ArrayList
      TheClasses.Add(ClassSizes) ;
    }
    //  Add the Classes Arraylist to the Session
    Session("Classes") = TheClasses;
    //  Create an Arraylist of the size of ClassSizes and bind it to the Radio List
    radSeatsAvailable.DataSour ce = PopulateArrayList(ClassSiz es);
    radSeatsAvailable.DataBind ();
  }
 private void InitialiseClasses() {
    ClassSizes = 15;
    AmountofClasse = 3;
    ArrayList TheClasses = new ArrayList();
    // Warning!!! Optional parameters not supported
    // Warning!!! Optional parameters not supported
    int i;
    //  For the Amount of Classes Specified
    for (i = 1; (i <= AmountofClasses); i++) {
      //  Add an integer of size ClassSizes to the ArrayList
      TheClasses.Add(ClassSizes)
    }
    //  Add the Classes Arraylist to the Session
    Session("Classes") = TheClasses;
    //  Create an Arraylist of the size of ClassSizes and bind it to the Radio List
    radSeatsAvailable.DataSour
    radSeatsAvailable.DataBind
  }
 private void InitialiseClasses(int ClassSizes, int AmountofClasse) {
    ArrayList TheClasses = new ArrayList();
    int i;
    //  For the Amount of Classes Specified
    for (i = 1; (i <= AmountofClasses); i++) {
      //  Add an integer of size ClassSizes to the ArrayList
      TheClasses.Add(ClassSizes)
    }
    //  Add the Classes Arraylist to the Session
    Session("Classes") = TheClasses;
    //  Create an Arraylist of the size of ClassSizes and bind it to the Radio List
    radSeatsAvailable.DataSour
    radSeatsAvailable.DataBind
  }
Or even better, with this....
 private void InitialiseClasses() {
    ClassSizes = 15;
    AmountofClasse = 3;
    InitialiseClasses(ClassSiz es, AmountofClasse);
}
 private void InitialiseClasses(int ClassSizes, int AmountofClasse) {
    ArrayList TheClasses = new ArrayList();
    int i;
    //  For the Amount of Classes Specified
    for (i = 1; (i <= AmountofClasses); i++) {
      //  Add an integer of size ClassSizes to the ArrayList
      TheClasses.Add(ClassSizes) ;
    }
    //  Add the Classes Arraylist to the Session
    Session("Classes") = TheClasses;
    //  Create an Arraylist of the size of ClassSizes and bind it to the Radio List
    radSeatsAvailable.DataSour ce = PopulateArrayList(ClassSiz es);
    radSeatsAvailable.DataBind ();
  }
 private void InitialiseClasses() {
    ClassSizes = 15;
    AmountofClasse = 3;
    InitialiseClasses(ClassSiz
}
 private void InitialiseClasses(int ClassSizes, int AmountofClasse) {
    ArrayList TheClasses = new ArrayList();
    int i;
    //  For the Amount of Classes Specified
    for (i = 1; (i <= AmountofClasses); i++) {
      //  Add an integer of size ClassSizes to the ArrayList
      TheClasses.Add(ClassSizes)
    }
    //  Add the Classes Arraylist to the Session
    Session("Classes") = TheClasses;
    //  Create an Arraylist of the size of ClassSizes and bind it to the Radio List
    radSeatsAvailable.DataSour
    radSeatsAvailable.DataBind
  }
ASKER
got this error now
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0118: 'System.Web.UI.Page.Sessio n' is a 'property' but is used like a 'method'
Source Error:
Â
Line 40: Â Â Â Â }
Line 41: Â Â Â Â // Â Add the Classes Arraylist to the Session
Line 42: Â Â Â Â Session("Classes") = TheClasses;
Line 43: Â Â Â Â // Â Create an Arraylist of the size of ClassSizes and bind it to the Radio List
Line 44: Â Â Â Â radSeatsAvailable.DataSour ce = PopulateArrayList(ClassSiz es);
Â
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0118: 'System.Web.UI.Page.Sessio
Source Error:
Â
Line 40: Â Â Â Â }
Line 41: Â Â Â Â // Â Add the Classes Arraylist to the Session
Line 42: Â Â Â Â Session("Classes") = TheClasses;
Line 43: Â Â Â Â // Â Create an Arraylist of the size of ClassSizes and bind it to the Radio List
Line 44: Â Â Â Â radSeatsAvailable.DataSour
Â
try
Session["Classes"] = TheClasses;
Session["Classes"] = TheClasses;
ASKER
that solved that issues here is another one
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0117: 'object' does not contain a definition for 'Item'
Source Error:
Â
Line 61: Â Â protected void ddlClass_SelectedIndexChan ged(object sender, System.EventArgs e) {
Line 62: Â Â Â Â // Â ReBind the radiolist based on the amount of seats left in the class
Line 63: Â Â Â Â radSeatsAvailable.DataSour ce = PopulateArrayList(Session[ "classes"] .Item[ddlC lass.Selec tedIndex]. ToString);
Line 64: Â Â Â Â radSeatsAvailable.DataBind ();
Line 65: Â Â Â Â UpdateLabels();
Â
Source File: C:\Inetpub\int422_071sq08\ webcontent \Labs\lab2 .aspx.cs   Line: 63
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0117: 'object' does not contain a definition for 'Item'
Source Error:
Â
Line 61: Â Â protected void ddlClass_SelectedIndexChan
Line 62: Â Â Â Â // Â ReBind the radiolist based on the amount of seats left in the class
Line 63: Â Â Â Â radSeatsAvailable.DataSour
Line 64: Â Â Â Â radSeatsAvailable.DataBind
Line 65: Â Â Â Â UpdateLabels();
Â
Source File: C:\Inetpub\int422_071sq08\
In C# you need to type everything. Â objects in Session are object types. Â To access their members you need to explicitly convert them to what they are.
radSeatsAvailable.DataSour ce = PopulateArrayList(((ArrayL ist )Session["classes"]).Item[ ddlClass.S electedInd ex].ToStri ng);
radSeatsAvailable.DataSour
ASKER
its not helping me man... lots of error... not sure what to do
ASKER
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0117: 'object' does not contain a definition for 'Item'
Source Error:
Â
Line 61: Â Â protected void ddlClass_SelectedIndexChan ged(object sender, System.EventArgs e) {
Line 62: Â Â Â Â // Â ReBind the radiolist based on the amount of seats left in the class
Line 63: Â Â Â Â radSeatsAvailable.DataSour ce = PopulateArrayList(Session[ "classes"] .Item[ddlC lass.Selec tedIndex]. ToString);
Line 64: Â Â Â Â radSeatsAvailable.DataBind ();
Line 65: Â Â Â Â UpdateLabels();
Â
Compiler Error Message: CS0117: 'object' does not contain a definition for 'Item'
Source Error:
Â
Line 61: Â Â protected void ddlClass_SelectedIndexChan
Line 62: Â Â Â Â // Â ReBind the radiolist based on the amount of seats left in the class
Line 63: Â Â Â Â radSeatsAvailable.DataSour
Line 64: Â Â Â Â radSeatsAvailable.DataBind
Line 65: Â Â Â Â UpdateLabels();
Â
This is the same exact error as above, you need to type Session["classes"] to an ArrayList
radSeatsAvailable.DataSour ce = PopulateArrayList(((ArrayL ist )Session["classes"]).Item[ ddlClass.S electedInd ex].ToStri ng);
or to make it easier to understand....
ArrayList x = (ArrayList) Session["classes"];
radSeatsAvailable.DataSour ce = PopulateArrayList(x.Item[d dlClass.Se lectedInde x].ToStrin g);
radSeatsAvailable.DataBind ();
UpdateLabels();
radSeatsAvailable.DataSour
or to make it easier to understand....
ArrayList x = (ArrayList) Session["classes"];
radSeatsAvailable.DataSour
radSeatsAvailable.DataBind
UpdateLabels();
ASKER
this one now
Â
Line 26: Â Â
Line 27:
Line 28: Â Â private ArrayList PopulateArrayList(int ArrayListLength) {
Line 29: Â Â Â Â ArrayList myarray = new ArrayList();
Line 30: Â Â Â Â int i;
Â
Â
Line 26: Â Â
Line 27:
Line 28: Â Â private ArrayList PopulateArrayList(int ArrayListLength) {
Line 29: Â Â Â Â ArrayList myarray = new ArrayList();
Line 30: Â Â Â Â int i;
Â
Try
System.Collections.ArrayLi st myarray = new System.Collections.ArrayLi st(ArrayLi stLength);
System.Collections.ArrayLi
http://www.carlosag.net/Tools/CodeTranslator/Default.aspx