in my asp.net+vb web with access database in a gridview i used the following code
Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
If (e.Row.DataItem("TEN") > 24) Then
e.Row.ForeColor = Drawing.Color.Red
End If
End sub
Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.DataBound
Label2.Text = GridView1.Rows.Count.ToString()
End Sub
the above code is working in my sqldatabase web but not working in access database web
If e.Row.RowType = DataControlRowType.DataRow Then
If (DataBinder.Eval(e.Row.DataItem, "TEN") > 24) Then
e.Row.ForeColor = Drawing.Color.Red
End If
End If
Programming to simplify, dont look for hard way
Suwandi - Non Graduate Programmer
Baiju EP
Member
178 Points
439 Posts
Change row colour as per data in gridview
Jan 25, 2013 04:10 PM|LINK
in my asp.net+vb web with access database in a gridview i used the following code
Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then If (e.Row.DataItem("TEN") > 24) Then e.Row.ForeColor = Drawing.Color.Red End If End sub Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.DataBound Label2.Text = GridView1.Rows.Count.ToString() End Subthe above code is working in my sqldatabase web but not working in access database web
goel.ankit
Contributor
2531 Points
513 Posts
Re: Change row colour as per data in gridview
Jan 25, 2013 04:16 PM|LINK
As far as you are getting the correct values from the database, your logic should work irrespective of database.
Check if you have proper values and debug the code.
Ankit
(Please select 'Mark as Answer' if my response has helped you.)
oned_gk
All-Star
36078 Points
7363 Posts
Re: Change row colour as per data in gridview
Jan 25, 2013 10:38 PM|LINK
If e.Row.RowType = DataControlRowType.DataRow Then If (DataBinder.Eval(e.Row.DataItem, "TEN") > 24) Then e.Row.ForeColor = Drawing.Color.Red End If End IfSuwandi - Non Graduate Programmer
Baiju EP
Member
178 Points
439 Posts
Re: Change row colour as per data in gridview
Jan 26, 2013 06:37 AM|LINK
nothing happens no colour change in rows having TEN>24
demoninside9
Participant
1626 Points
1823 Posts
Re: Change row colour as per data in gridview
Jan 30, 2013 09:15 AM|LINK
could you please shows your code file code and data which is in database ?
try to convert your gridview cell value to Integer.
try this
protected void GVEmployee_RowDataBound(object sender, GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { if (Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "TEN")) > 24) { e.Row.BackColor = System.Drawing.Color.Black; e.Row.ForeColor = System.Drawing.Color.White; } } }Gaurav
paindaasp
Star
12252 Points
2070 Posts
Re: Change row colour as per data in gridview
Jan 30, 2013 10:54 AM|LINK
Are you missing the Handles clause? Are you really executing the sub? Try:
demoninside9
Participant
1626 Points
1823 Posts
Re: Change row colour as per data in gridview
Jan 31, 2013 02:02 AM|LINK
did you try my code ?
Gaurav
Baiju EP
Member
178 Points
439 Posts
Re: Change row colour as per data in gridview
Feb 02, 2013 02:12 AM|LINK
thanks a lot paindaasp i was missing Handles GridView1.RowDataBound
now it works fine
paindaasp
Star
12252 Points
2070 Posts
Re: Change row colour as per data in gridview
Feb 02, 2013 04:35 AM|LINK
Baiju EP
Member
178 Points
439 Posts
Re: Change row colour as per data in gridview
Feb 02, 2013 05:59 AM|LINK
no because i am using vb code in my asp.net web. i will tr it after converting to vb thhanks a lot for responding