473,320 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

don't know which kind of object to select in a gridview

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
Jul 6 '06 #1
0 859

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Terry | last post by:
Good morning! How do I determine which SELECT button was clicked in a GridView? The multiple SELECT buttons will be used for an application approval process. Thank you in advance for your...
2
by: Olivier Matrot | last post by:
Hello, I'm using a gridview with objectdatasource and custom objects collections SELECT/INSERT/UPDATE/DELETE methods are using custom objects as parameters. This is working fine. But I have a...
2
by: Greg | last post by:
Hello, I am trying to bind a GridView to a custom object I have created. First, here is what I'm trying to do: I have a wizard for adding/editing Users. When the wizard begins, a User...
1
by: Kat | last post by:
I have a gridview that queries a stored procedure to select id, firstname, lastname from clients. Then I have a detailsview that queries the client details linked to the id from the client...
1
by: Chris | last post by:
I have a gridview bound to the select method of an object data source. I have a filter button, that when clicked applies a filter typed in a textbox. How do I change the select method of the object...
4
by: hharry | last post by:
Hello All, I am binding a custom business object the gridview control. When I bind a datatable to the gridview control, the columns are displayed in the same order as the select statement used...
0
by: David C | last post by:
I am getting this error in the Databound event of a GridView and I am having a difficult time debugging. I do not get the error on every record that I edit in the GridView. The error is occurring...
0
by: Russ | last post by:
I have a gridview that is bound to a datasourceobject. This is part of a user control (ascx). I have a "Close" button and a "Save" button. When either of these buttons are clicked I want to...
15
JustRun
by: JustRun | last post by:
I have a problem with the select option at the gridview and gonna pull my hair out cause it doesn't work at all. Here is the Grid view code: I want to get the selected row when the user click...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.