ArgumentException and ArgumentOutOfRangeException

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Zoe Elmo
    New Member
    • Mar 2007
    • 7

    ArgumentException and ArgumentOutOfRangeException

    hello everybody,

    <first of all i am sorry if i have already submitted similar thread, because i wasnt sure whether this thread has been submitted since i was redirected to the login page>

    i am working on a project on .net CF using VB. in my project, i have a datagrid which is bind it to a datasource as below (in form activated):

    ds = Globall.ReadXML .ReadStudentXML <-- reading from a class
    With DataGrid1
    .DataSource = ds.Tables("stud ent")
    .DataBindings.C lear()
    .DataBindings() .Add("Text", .DataSource, "StudID")

    then in my mouseUp event, where i click on a row header in the datagrid, i would want to filter the row according to the primary key and display only the row's information to some label controls. i did a filter and some data binding to label as below :

    With DataGrid1

    If .HitTest(e.X, e.Y).Type = HitTestType.Row Header Then

    ds.Tables("stud ent").DefaultVi ew.RowFilter = "StudID= ' " &DataGrid1.T ext & "' " <--- this is the primary key that i bind to the datagrid earlier i (i am not sure whether this is correct)

    lblID.DataBindi ngs.Add("Text", ds.Tables("stud ent"), "StudID")
    lblName.DataBin dings.Add("Text ",ds.Tables("st udent"), "StudName")
    lblClass.DataBi ndings.Add("Tex t",ds.Tables("s tudent"), "Class")

    End If
    End With


    This code works fine for the the few rows of the datagrid. But when i select the 5th row of the datagrid, it throws the exception "ArgumentExcept ion"

    I am confused as to what happened. i tried several other ways, such as putting the lbl.databinding s in the form activated, but it returned the ArgumentOutOfRa nge Exception.

    i suspect the problem came from this line :

    ds.Tables("stud ent").DefaultVi ew.RowFilter = "StudID= ' " &DataGrid1.T ext & "' "

    but i dont know how to fix it nor i see anything wrong with it.. Please help to give advise.. i've been working on this for two days, and yet i dont know what is wrong with it.

    fyi : what i want to do is just access the value on the datagrid, instead of the value in the underlying datasource object and display it on the label control.

    Hope someone could help.. Thanks in advance

    regards,
    Zoe
  • vijaydiwakar
    Contributor
    • Feb 2007
    • 579

    #2
    Originally posted by Zoe Elmo
    hello everybody,

    <first of all i am sorry if i have already submitted similar thread, because i wasnt sure whether this thread has been submitted since i was redirected to the login page>

    i am working on a project on .net CF using VB. in my project, i have a datagrid which is bind it to a datasource as below (in form activated):

    ds = Globall.ReadXML .ReadStudentXML <-- reading from a class
    With DataGrid1
    .DataSource = ds.Tables("stud ent")
    .DataBindings.C lear()
    .DataBindings() .Add("Text", .DataSource, "StudID")

    then in my mouseUp event, where i click on a row header in the datagrid, i would want to filter the row according to the primary key and display only the row's information to some label controls. i did a filter and some data binding to label as below :

    With DataGrid1

    If .HitTest(e.X, e.Y).Type = HitTestType.Row Header Then

    ds.Tables("stud ent").DefaultVi ew.RowFilter = "StudID= ' " &DataGrid1.T ext & "' " <--- this is the primary key that i bind to the datagrid earlier i (i am not sure whether this is correct)

    lblID.DataBindi ngs.Add("Text", ds.Tables("stud ent"), "StudID")
    lblName.DataBin dings.Add("Text ",ds.Tables("st udent"), "StudName")
    lblClass.DataBi ndings.Add("Tex t",ds.Tables("s tudent"), "Class")

    End If
    End With


    This code works fine for the the few rows of the datagrid. But when i select the 5th row of the datagrid, it throws the exception "ArgumentExcept ion"

    I am confused as to what happened. i tried several other ways, such as putting the lbl.databinding s in the form activated, but it returned the ArgumentOutOfRa nge Exception.

    i suspect the problem came from this line :

    ds.Tables("stud ent").DefaultVi ew.RowFilter = "StudID= ' " &DataGrid1.T ext & "' "

    but i dont know how to fix it nor i see anything wrong with it.. Please help to give advise.. i've been working on this for two days, and yet i dont know what is wrong with it.

    fyi : what i want to do is just access the value on the datagrid, instead of the value in the underlying datasource object and display it on the label control.

    Hope someone could help.. Thanks in advance

    regards,
    Zoe
    what's d value in 5th row for stuidid?
    what's the type of studid in db?
    explain with some techinical details

    Comment

    • Zoe Elmo
      New Member
      • Mar 2007
      • 7

      #3
      Originally posted by vijaydiwakar
      what's d value in 5th row for stuidid?
      what's the type of studid in db?
      explain with some techinical details

      the studID is of type varchar. In fact, not only the 5th row, all the rows after that cannot be retrieved. The studID for the rows are as below :

      1st : CB001
      2nd: CB002
      3rd: CB003
      4th: CB004
      5th: CB005
      6th: CB006 and
      7th: CB007

      i am using sqlserver 2000 and i pull all the data into dataset, write to xml and read from the xml file into dataset for further manipulation.

      thank you

      Comment

      Working...