error: Specified argument was out of the range of valid values. Parameter name: index

Discussion in 'ASP .Net Datagrid Control' started by Dave, Jul 7, 2006.

  1. Dave

    Dave Guest

    Hi,

    I want to change the color of two fields (a checkbox and a 'normal
    stringfield') of my gridview depending of their value. The checkbox works
    with the code below.
    My question is: what do i have to take as object for the 'normal
    stringfield'? I tried with 'textbox', with 'label' ... but each time i get
    the error:
    "Specified argument was out of the range of valid values. Parameter name:
    index"

    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    GridView1.RowDataBound
    Dim cb As New CheckBox
    Dim a As ???
    cb = e.Row.Cells(6).Controls(0)
    a = e.Row.Cells(5).Controls(0)
    If cb.Checked Then
    e.Row.Cells(0).BackColor = Drawing.Color.Red
    e.Row.Cells(6).BackColor = Drawing.Color.Red
    End If

    if a.text (or matbe a.value) = "fat" then
    e.Row.Cells(6).BackColor = Drawing.Color.Green
    End If
    End Sub

    Thanks
    Dave
     
    Dave, Jul 7, 2006
    #1
    1. Advertising

  2. Dave

    Winista Guest

    In case of text, the cell itself has the text value set on it. You can skip
    the part where you are looking for control at index 0.


    "Dave" <vqsvd@sdvsd> wrote in message
    news:%...
    > Hi,
    >
    > I want to change the color of two fields (a checkbox and a 'normal
    > stringfield') of my gridview depending of their value. The checkbox works
    > with the code below.
    > My question is: what do i have to take as object for the 'normal
    > stringfield'? I tried with 'textbox', with 'label' ... but each time i get
    > the error:
    > "Specified argument was out of the range of valid values. Parameter name:
    > index"
    >
    > Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    > GridView1.RowDataBound
    > Dim cb As New CheckBox
    > Dim a As ???
    > cb = e.Row.Cells(6).Controls(0)
    > a = e.Row.Cells(5).Controls(0)
    > If cb.Checked Then
    > e.Row.Cells(0).BackColor = Drawing.Color.Red
    > e.Row.Cells(6).BackColor = Drawing.Color.Red
    > End If
    >
    > if a.text (or matbe a.value) = "fat" then
    > e.Row.Cells(6).BackColor = Drawing.Color.Green
    > End If
    > End Sub
    >
    > Thanks
    > Dave
    >
    >
    >
     
    Winista, Jul 7, 2006
    #2
    1. Advertising

  3. Dave

    Winista Guest

    PArdon my VB :) I am not good at it..

    You are trying to get the text in that cell. And then use that to check the
    condition. You can do something like.

    Dim aText As String


    aText = e.Row.Cells(5).Text

    if aText = "fat" then

    Try it out...

    "Dave" <vqsvd@sdvsd> wrote in message
    news:...
    > Thanks for replying,but forgive me if i don't understand what you mean ...
    >
    > I still don't know how to finish the line:
    > dim as as ... (textbox ??)
    > and when doing that, i still get the mentioned error ...
    >
    > If possible, can you show me the right code ...
    > Thanks
    >
    > "Winista" <> schreef in bericht
    > news:%...
    >> In case of text, the cell itself has the text value set on it. You can
    >> skip the part where you are looking for control at index 0.
    >>
    >>
    >> "Dave" <vqsvd@sdvsd> wrote in message
    >> news:%...
    >>> Hi,
    >>>
    >>> I want to change the color of two fields (a checkbox and a 'normal
    >>> stringfield') of my gridview depending of their value. The checkbox
    >>> works
    >>> with the code below.
    >>> My question is: what do i have to take as object for the 'normal
    >>> stringfield'? I tried with 'textbox', with 'label' ... but each time i
    >>> get
    >>> the error:
    >>> "Specified argument was out of the range of valid values. Parameter
    >>> name:
    >>> index"
    >>>
    >>> Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
    >>> System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    >>> GridView1.RowDataBound
    >>> Dim cb As New CheckBox
    >>> Dim a As ???
    >>> cb = e.Row.Cells(6).Controls(0)
    >>> a = e.Row.Cells(5).Controls(0)
    >>> If cb.Checked Then
    >>> e.Row.Cells(0).BackColor = Drawing.Color.Red
    >>> e.Row.Cells(6).BackColor = Drawing.Color.Red
    >>> End If
    >>>
    >>> if a.text (or matbe a.value) = "fat" then
    >>> e.Row.Cells(6).BackColor = Drawing.Color.Green
    >>> End If
    >>> End Sub
    >>>
    >>> Thanks
    >>> Dave
    >>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    Winista, Jul 8, 2006
    #3
  4. Dave

    Dave Guest

    Thanks for replying,but forgive me if i don't understand what you mean ...

    I still don't know how to finish the line:
    dim as as ... (textbox ??)
    and when doing that, i still get the mentioned error ...

    If possible, can you show me the right code ...
    Thanks

    "Winista" <> schreef in bericht
    news:%...
    > In case of text, the cell itself has the text value set on it. You can
    > skip the part where you are looking for control at index 0.
    >
    >
    > "Dave" <vqsvd@sdvsd> wrote in message
    > news:%...
    >> Hi,
    >>
    >> I want to change the color of two fields (a checkbox and a 'normal
    >> stringfield') of my gridview depending of their value. The checkbox works
    >> with the code below.
    >> My question is: what do i have to take as object for the 'normal
    >> stringfield'? I tried with 'textbox', with 'label' ... but each time i
    >> get
    >> the error:
    >> "Specified argument was out of the range of valid values. Parameter name:
    >> index"
    >>
    >> Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
    >> System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    >> GridView1.RowDataBound
    >> Dim cb As New CheckBox
    >> Dim a As ???
    >> cb = e.Row.Cells(6).Controls(0)
    >> a = e.Row.Cells(5).Controls(0)
    >> If cb.Checked Then
    >> e.Row.Cells(0).BackColor = Drawing.Color.Red
    >> e.Row.Cells(6).BackColor = Drawing.Color.Red
    >> End If
    >>
    >> if a.text (or matbe a.value) = "fat" then
    >> e.Row.Cells(6).BackColor = Drawing.Color.Green
    >> End If
    >> End Sub
    >>
    >> Thanks
    >> Dave
    >>
    >>
    >>

    >
    >
     
    Dave, Jul 8, 2006
    #4
  5. Dave

    Dave Guest

    Thanks, it works now ...

    But i still don't undertsand why this statement works: (independantely of
    property 'text')
    Dim cb As New CheckBox
    cb = e.Row.Cells(6).Controls(0)

    but not this: (gives mentioned error)
    Dim a As new textbox
    a = e.Row.Cells(5).Controls(0)

    Thansk again

    "Winista" <> schreef in bericht
    news:...
    > PArdon my VB :) I am not good at it..
    >
    > You are trying to get the text in that cell. And then use that to check
    > the condition. You can do something like.
    >
    > Dim aText As String
    >
    >
    > aText = e.Row.Cells(5).Text
    >
    > if aText = "fat" then
    >
    > Try it out...
    >
    > "Dave" <vqsvd@sdvsd> wrote in message
    > news:...
    >> Thanks for replying,but forgive me if i don't understand what you mean
    >> ...
    >>
    >> I still don't know how to finish the line:
    >> dim as as ... (textbox ??)
    >> and when doing that, i still get the mentioned error ...
    >>
    >> If possible, can you show me the right code ...
    >> Thanks
    >>
    >> "Winista" <> schreef in bericht
    >> news:%...
    >>> In case of text, the cell itself has the text value set on it. You can
    >>> skip the part where you are looking for control at index 0.
    >>>
    >>>
    >>> "Dave" <vqsvd@sdvsd> wrote in message
    >>> news:%...
    >>>> Hi,
    >>>>
    >>>> I want to change the color of two fields (a checkbox and a 'normal
    >>>> stringfield') of my gridview depending of their value. The checkbox
    >>>> works
    >>>> with the code below.
    >>>> My question is: what do i have to take as object for the 'normal
    >>>> stringfield'? I tried with 'textbox', with 'label' ... but each time i
    >>>> get
    >>>> the error:
    >>>> "Specified argument was out of the range of valid values. Parameter
    >>>> name:
    >>>> index"
    >>>>
    >>>> Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
    >>>> System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    >>>> GridView1.RowDataBound
    >>>> Dim cb As New CheckBox
    >>>> Dim a As ???
    >>>> cb = e.Row.Cells(6).Controls(0)
    >>>> a = e.Row.Cells(5).Controls(0)
    >>>> If cb.Checked Then
    >>>> e.Row.Cells(0).BackColor = Drawing.Color.Red
    >>>> e.Row.Cells(6).BackColor = Drawing.Color.Red
    >>>> End If
    >>>>
    >>>> if a.text (or matbe a.value) = "fat" then
    >>>> e.Row.Cells(6).BackColor = Drawing.Color.Green
    >>>> End If
    >>>> End Sub
    >>>>
    >>>> Thanks
    >>>> Dave
    >>>>
    >>>>
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    Dave, Jul 8, 2006
    #5
  6. Re: error: Specified argument was out of the range of valid values.

    Dave wrote:
    > Thanks, it works now ...
    >
    > But i still don't undertsand why this statement works: (independantely of
    > property 'text')
    > Dim cb As New CheckBox
    > cb = e.Row.Cells(6).Controls(0)
    >
    > but not this: (gives mentioned error)
    > Dim a As new textbox
    > a = e.Row.Cells(5).Controls(0)
    >


    I guess it would be because Cells(5) contains no controls, so
    Controls(0) is out of range.

    Jesse

    > Thansk again
    >
    > "Winista" <> schreef in bericht
    > news:...
    >> PArdon my VB :) I am not good at it..
    >>
    >> You are trying to get the text in that cell. And then use that to check
    >> the condition. You can do something like.
    >>
    >> Dim aText As String
    >>
    >>
    >> aText = e.Row.Cells(5).Text
    >>
    >> if aText = "fat" then
    >>
    >> Try it out...
    >>
    >> "Dave" <vqsvd@sdvsd> wrote in message
    >> news:...
    >>> Thanks for replying,but forgive me if i don't understand what you mean
    >>> ...
    >>>
    >>> I still don't know how to finish the line:
    >>> dim as as ... (textbox ??)
    >>> and when doing that, i still get the mentioned error ...
    >>>
    >>> If possible, can you show me the right code ...
    >>> Thanks
    >>>
    >>> "Winista" <> schreef in bericht
    >>> news:%...
    >>>> In case of text, the cell itself has the text value set on it. You can
    >>>> skip the part where you are looking for control at index 0.
    >>>>
    >>>>
    >>>> "Dave" <vqsvd@sdvsd> wrote in message
    >>>> news:%...
    >>>>> Hi,
    >>>>>
    >>>>> I want to change the color of two fields (a checkbox and a 'normal
    >>>>> stringfield') of my gridview depending of their value. The checkbox
    >>>>> works
    >>>>> with the code below.
    >>>>> My question is: what do i have to take as object for the 'normal
    >>>>> stringfield'? I tried with 'textbox', with 'label' ... but each time i
    >>>>> get
    >>>>> the error:
    >>>>> "Specified argument was out of the range of valid values. Parameter
    >>>>> name:
    >>>>> index"
    >>>>>
    >>>>> Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
    >>>>> System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    >>>>> GridView1.RowDataBound
    >>>>> Dim cb As New CheckBox
    >>>>> Dim a As ???
    >>>>> cb = e.Row.Cells(6).Controls(0)
    >>>>> a = e.Row.Cells(5).Controls(0)
    >>>>> If cb.Checked Then
    >>>>> e.Row.Cells(0).BackColor = Drawing.Color.Red
    >>>>> e.Row.Cells(6).BackColor = Drawing.Color.Red
    >>>>> End If
    >>>>>
    >>>>> if a.text (or matbe a.value) = "fat" then
    >>>>> e.Row.Cells(6).BackColor = Drawing.Color.Green
    >>>>> End If
    >>>>> End Sub
    >>>>>
    >>>>> Thanks
    >>>>> Dave
    >>>>>
    >>>>>
    >>>>>
    >>>>
    >>>

    >>

    >
    >
     
    Jesse Houwing, Jul 8, 2006
    #6
  7. Dave

    Dave Guest

    Hi Jesse,

    The gridview contains 7 fields (i can see them on screen). The last is a
    checkbox and the first six are textfield.
    So e.Row.Cells(6).Controls(0) is the checkbox, but why are
    e.Row.Cells(0).Controls(0) till e.Row.Cells(5).Controls(0) out of range ???

    Maybe are these texrfield not 'textbox'? But then, what are they? How can i
    know that?
    Thanks


    "Jesse Houwing" <> schreef in bericht
    news:%23vit%...
    > Dave wrote:
    >> Thanks, it works now ...
    >>
    >> But i still don't undertsand why this statement works: (independantely of
    >> property 'text')
    >> Dim cb As New CheckBox
    >> cb = e.Row.Cells(6).Controls(0)
    >>
    >> but not this: (gives mentioned error)
    >> Dim a As new textbox
    >> a = e.Row.Cells(5).Controls(0)
    >>

    >
    > I guess it would be because Cells(5) contains no controls, so Controls(0)
    > is out of range.
    >
    > Jesse
    >
    >> Thansk again
    >>
    >> "Winista" <> schreef in bericht
    >> news:...
    >>> PArdon my VB :) I am not good at it..
    >>>
    >>> You are trying to get the text in that cell. And then use that to check
    >>> the condition. You can do something like.
    >>>
    >>> Dim aText As String
    >>>
    >>>
    >>> aText = e.Row.Cells(5).Text
    >>>
    >>> if aText = "fat" then
    >>>
    >>> Try it out...
    >>>
    >>> "Dave" <vqsvd@sdvsd> wrote in message
    >>> news:...
    >>>> Thanks for replying,but forgive me if i don't understand what you mean
    >>>> ...
    >>>>
    >>>> I still don't know how to finish the line:
    >>>> dim as as ... (textbox ??)
    >>>> and when doing that, i still get the mentioned error ...
    >>>>
    >>>> If possible, can you show me the right code ...
    >>>> Thanks
    >>>>
    >>>> "Winista" <> schreef in bericht
    >>>> news:%...
    >>>>> In case of text, the cell itself has the text value set on it. You can
    >>>>> skip the part where you are looking for control at index 0.
    >>>>>
    >>>>>
    >>>>> "Dave" <vqsvd@sdvsd> wrote in message
    >>>>> news:%...
    >>>>>> Hi,
    >>>>>>
    >>>>>> I want to change the color of two fields (a checkbox and a 'normal
    >>>>>> stringfield') of my gridview depending of their value. The checkbox
    >>>>>> works
    >>>>>> with the code below.
    >>>>>> My question is: what do i have to take as object for the 'normal
    >>>>>> stringfield'? I tried with 'textbox', with 'label' ... but each time
    >>>>>> i get
    >>>>>> the error:
    >>>>>> "Specified argument was out of the range of valid values. Parameter
    >>>>>> name:
    >>>>>> index"
    >>>>>>
    >>>>>> Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e
    >>>>>> As
    >>>>>> System.Web.UI.WebControls.GridViewRowEventArgs) Handles
    >>>>>> GridView1.RowDataBound
    >>>>>> Dim cb As New CheckBox
    >>>>>> Dim a As ???
    >>>>>> cb = e.Row.Cells(6).Controls(0)
    >>>>>> a = e.Row.Cells(5).Controls(0)
    >>>>>> If cb.Checked Then
    >>>>>> e.Row.Cells(0).BackColor = Drawing.Color.Red
    >>>>>> e.Row.Cells(6).BackColor = Drawing.Color.Red
    >>>>>> End If
    >>>>>>
    >>>>>> if a.text (or matbe a.value) = "fat" then
    >>>>>> e.Row.Cells(6).BackColor = Drawing.Color.Green
    >>>>>> End If
    >>>>>> End Sub
    >>>>>>
    >>>>>> Thanks
    >>>>>> Dave
    >>>>>>
    >>>>>>
    >>>>>>
    >>>>>
    >>>>
    >>>

    >>
     
    Dave, Jul 8, 2006
    #7
  8. Re: error: Specified argument was out of the range of valid values.

    Dave wrote:
    > Hi Jesse,
    >
    > The gridview contains 7 fields (i can see them on screen). The last is a
    > checkbox and the first six are textfield.
    > So e.Row.Cells(6).Controls(0) is the checkbox, but why are
    > e.Row.Cells(0).Controls(0) till e.Row.Cells(5).Controls(0) out of range ???
    >
    > Maybe are these texrfield not 'textbox'? But then, what are they? How can i
    > know that?


    Maybe they're just plain HTML input boxes. Or other plain text. Can you
    post the corresponding code from the ASPX?

    Jesse
     
    Jesse Houwing, Jul 8, 2006
    #8
  9. Dave

    Dave Guest

    Hi,

    Here below is the ASPX code:
    as you can see, they are 6 'Boundfield' and 1 checkfield, but when doing
    this:
    dim c as new BoundField
    c=e.Row.Cells(0).Controls(0)

    i get the error:"type 'System.Web.UI.Control' cannot be converted to
    'System.Web.UI.WebControls.BoundField'.

    I also tried with"Htmlinputtext", "tablecell" ...

    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\my.mdb"
    ProviderName="System.Data.OleDb" SelectCommand="SELECT fld1,
    fld2,fld3,fld4,fld5,fld6, fld7FROM mytable"></asp:SqlDataSource>

    <asp:GridView ID="GridView1" runat="server"
    <Columns>
    <asp:BoundField DataField="fld1"
    HeaderText="Computer"
    SortExpression="fld1" />
    <asp:BoundField DataField="fld2"
    HeaderText="Lok"
    SortExpression="fld2" />
    <asp:BoundField DataField="fld3"
    HeaderText="Oms"
    SortExpression="fld3" />
    <asp:BoundField DataField="fld4"
    HeaderText="Type"
    SortExpression="fld4" />
    <asp:BoundField DataField="fld5"
    HeaderText="Soft"
    SortExpression="fld5" />
    <asp:BoundField DataField="fld6
    HeaderText="Thin"
    SortExpression="fld6" />
    <asp:CheckBoxField DataField="fld7"
    HeaderText="Def"
    SortExpression="fld7" />
    </Columns>
    </asp:GridView>


    "Jesse Houwing" <> schreef in bericht
    news:...
    > Dave wrote:
    >> Hi Jesse,
    >>
    >> The gridview contains 7 fields (i can see them on screen). The last is a
    >> checkbox and the first six are textfield.
    >> So e.Row.Cells(6).Controls(0) is the checkbox, but why are
    >> e.Row.Cells(0).Controls(0) till e.Row.Cells(5).Controls(0) out of range
    >> ???
    >>
    >> Maybe are these texrfield not 'textbox'? But then, what are they? How can
    >> i know that?

    >
    > Maybe they're just plain HTML input boxes. Or other plain text. Can you
    > post the corresponding code from the ASPX?
    >
    > Jesse
     
    Dave, Jul 9, 2006
    #9
  10. Re: error: Specified argument was out of the range of valid values.

    * Dave wrote, On 9-7-2006 10:12:
    > Hi,
    >
    > Here below is the ASPX code:
    > as you can see, they are 6 'Boundfield' and 1 checkfield, but when doing
    > this:
    > dim c as new BoundField
    > c=e.Row.Cells(0).Controls(0)
    >
    > i get the error:"type 'System.Web.UI.Control' cannot be converted to
    > 'System.Web.UI.WebControls.BoundField'.
    >
    > I also tried with"Htmlinputtext", "tablecell" ...
    >
    > <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    > ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\my.mdb"
    > ProviderName="System.Data.OleDb" SelectCommand="SELECT fld1,
    > fld2,fld3,fld4,fld5,fld6, fld7FROM mytable"></asp:SqlDataSource>
    >
    > <asp:GridView ID="GridView1" runat="server"
    > <Columns>
    > <asp:BoundField DataField="fld1"
    > HeaderText="Computer"
    > SortExpression="fld1" />
    > <asp:BoundField DataField="fld2"
    > HeaderText="Lok"
    > SortExpression="fld2" />
    > <asp:BoundField DataField="fld3"
    > HeaderText="Oms"
    > SortExpression="fld3" />
    > <asp:BoundField DataField="fld4"
    > HeaderText="Type"
    > SortExpression="fld4" />
    > <asp:BoundField DataField="fld5"
    > HeaderText="Soft"
    > SortExpression="fld5" />
    > <asp:BoundField DataField="fld6
    > HeaderText="Thin"
    > SortExpression="fld6" />
    > <asp:CheckBoxField DataField="fld7"
    > HeaderText="Def"
    > SortExpression="fld7" />
    > </Columns>
    > </asp:GridView>
    >
    >
    > "Jesse Houwing" <> schreef in bericht
    > news:...
    >> Dave wrote:
    >>> Hi Jesse,
    >>>
    >>> The gridview contains 7 fields (i can see them on screen). The last is a
    >>> checkbox and the first six are textfield.
    >>> So e.Row.Cells(6).Controls(0) is the checkbox, but why are
    >>> e.Row.Cells(0).Controls(0) till e.Row.Cells(5).Controls(0) out of range
    >>> ???
    >>>
    >>> Maybe are these texrfield not 'textbox'? But then, what are they? How can
    >>> i know that?

    >> Maybe they're just plain HTML input boxes. Or other plain text. Can you
    >> post the corresponding code from the ASPX?
    >>
    >> Jesse

    >
    >


    The last field contains a checkbox which will be represented as a
    control, the others are just bound text which will not create a control.
    To get to that text from your code-behind you should use

    e.Row.Cells(0).Text

    A control will only be added if the row is in edit mode (then it wil
    contain a textbox control).

    Should you always want a conrtol in there for some reason, use a
    templatecolumn and then you can put in any controls you'd want.

    Jesse
     
    Jesse Houwing, Jul 9, 2006
    #10
  11. Dave

    dave Guest

    Thanks!


    "Jesse Houwing" <> wrote in message
    news:...
    > * Dave wrote, On 9-7-2006 10:12:
    > > Hi,
    > >
    > > Here below is the ASPX code:
    > > as you can see, they are 6 'Boundfield' and 1 checkfield, but when doing
    > > this:
    > > dim c as new BoundField
    > > c=e.Row.Cells(0).Controls(0)
    > >
    > > i get the error:"type 'System.Web.UI.Control' cannot be converted to
    > > 'System.Web.UI.WebControls.BoundField'.
    > >
    > > I also tried with"Htmlinputtext", "tablecell" ...
    > >
    > > <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    > > ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data

    Source=c:\my.mdb"
    > > ProviderName="System.Data.OleDb" SelectCommand="SELECT fld1,
    > > fld2,fld3,fld4,fld5,fld6, fld7FROM mytable"></asp:SqlDataSource>
    > >
    > > <asp:GridView ID="GridView1" runat="server"
    > > <Columns>
    > > <asp:BoundField DataField="fld1"
    > > HeaderText="Computer"
    > > SortExpression="fld1" />
    > > <asp:BoundField DataField="fld2"
    > > HeaderText="Lok"
    > > SortExpression="fld2" />
    > > <asp:BoundField DataField="fld3"
    > > HeaderText="Oms"
    > > SortExpression="fld3" />
    > > <asp:BoundField DataField="fld4"
    > > HeaderText="Type"
    > > SortExpression="fld4" />
    > > <asp:BoundField DataField="fld5"
    > > HeaderText="Soft"
    > > SortExpression="fld5" />
    > > <asp:BoundField DataField="fld6
    > > HeaderText="Thin"
    > > SortExpression="fld6" />
    > > <asp:CheckBoxField DataField="fld7"
    > > HeaderText="Def"
    > > SortExpression="fld7" />
    > > </Columns>
    > > </asp:GridView>
    > >
    > >
    > > "Jesse Houwing" <> schreef in bericht
    > > news:...
    > >> Dave wrote:
    > >>> Hi Jesse,
    > >>>
    > >>> The gridview contains 7 fields (i can see them on screen). The last is

    a
    > >>> checkbox and the first six are textfield.
    > >>> So e.Row.Cells(6).Controls(0) is the checkbox, but why are
    > >>> e.Row.Cells(0).Controls(0) till e.Row.Cells(5).Controls(0) out of

    range
    > >>> ???
    > >>>
    > >>> Maybe are these texrfield not 'textbox'? But then, what are they? How

    can
    > >>> i know that?
    > >> Maybe they're just plain HTML input boxes. Or other plain text. Can you
    > >> post the corresponding code from the ASPX?
    > >>
    > >> Jesse

    > >
    > >

    >
    > The last field contains a checkbox which will be represented as a
    > control, the others are just bound text which will not create a control.
    > To get to that text from your code-behind you should use
    >
    > e.Row.Cells(0).Text
    >
    > A control will only be added if the row is in edit mode (then it wil
    > contain a textbox control).
    >
    > Should you always want a conrtol in there for some reason, use a
    > templatecolumn and then you can put in any controls you'd want.
    >
    > Jesse
     
    dave, Jul 9, 2006
    #11
  12. Re: error: Specified argument was out of the range of valid values.

    * dave wrote, On 9-7-2006 15:14:
    > Thanks!


    You're welcome!

    Jesse
     
    Jesse Houwing, Jul 9, 2006
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Todd Perkins
    Replies:
    0
    Views:
    9,456
    Todd Perkins
    Sep 15, 2004
  2. subdhar
    Replies:
    9
    Views:
    27,974
    Subhashish Dhar
    Nov 9, 2004
  3. darrel
    Replies:
    0
    Views:
    8,474
    darrel
    Aug 14, 2006
  4. Chapi
    Replies:
    2
    Views:
    10,873
    Chapi
    May 26, 2008
  5. Dave
    Replies:
    0
    Views:
    1,786
Loading...

Share This Page