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
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>