Change GridView Row Color Based On Condition In C#
I want to change a particular row color of gridview based on some condition, i am using ASP.NET with c#.
View 2 Replies (Posted: Feb 19 at 4:04)
Sponsored Links:
Related Forum Messages For ASP.NET category:
SQL Reporting :: Change Font Color Based On Condition?
I want to change the font color based on condition, I have a field of type "TimeSpan" and i wanted to change the color of that field(textbox). For example is the field value is equal to or more than 5 hours as "05:20:45" then the font color should be "Green" and if the field value is less than 5 hours as "04:12:35" then the font color should be "Red"
Posted: Dec 10, 2009 07:54 AM
View 4 Replies!
View Related
Change Gridview Row Color Based On Templatefields Without Controls
My gridview does not use controls, because it is populated using expressions <asp:TemplateField HeaderText="As Of Sales"> <ItemTemplate> <%#Getsales(Decimal.Parse(Eval("asofsales").ToString())).ToString("C0")%> </ItemTemplate> <FooterTemplate> <%#Getsales1().ToString("C0")%> </FooterTemplate> <FooterStyle Font-Bold="True" /> </asp:TemplateField> I want to compare column index 1 and column index 8, and if 8 is bigger then 1 it should be a different font color. Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then Dim x As String x = e.Row.Cells(1).Text Dim y As String y = e.Row.Cells(8).Text If Convert.ToInt32(x) <= Convert.ToInt32(y) Then e.Row.ForeColor = System.Drawing.Color.Blue End If End If End Sub
Posted: Feb 25 at 22:12
View 1 Replies!
View Related
C# - How To Check The CheckBox In A GridView Based On Condition
I have four textbox fields for ItemName, ItemDescription, Length and Quantity. One radiobuttonlist and its listitems are FixedLength and Random Length. One button field called Submit and one gridview. In the GridView I have 4 bound columns and 1 template column such as ItemName, ItemDescription, Length, Quantity and IsFixed_f(flag field). I have added one checkbox in the GridView's Template column for the IsFixed_f field. After entering all textbox fields, I have to select either one listitem in the radiobuttonlist(FixedLength or RandomLength). After completing these things. If I enter the Submit button, all the values in the textbox to be displayed under the GridView's corresponding column name and checkbox to be checked if FixedLength listitem is selected otherwise the checkbox.checked should be false. How to do this? In the Button Click event, i have used like this [code]....
Posted: Jan 11 at 9:26
View 3 Replies!
View Related
Web Forms :: Database Menu - Change Background Color Based On Current Location?
I am making an asp.net website and have decided to use a master page then use a sql database for the website navigation. Now what I wan't to do is when a user is on a page i want the background color of the link to be white. For example if the user was on the home page, the home link in the navigation bar would have a white background. I would prefer that the code to do this be in C# if at all possible. Oh by the way, i am using a repeater to display the links. Below is the code of the repeater. [Code]....
Posted: Dec 18, 2009 02:17 AM
View 3 Replies!
View Related
Forms Data Controls :: Gridview Detail Based Upon Checkbox Condition
I have three individual methods of searching for a particular product - a cascading drop down menu system with the final dd being the product ID; an autocomplete text box that a user can search for a product and select and finally, a blank text box where the user simply enters the product ID (note products are all being sourced from the same class using different methods i.e. a page method & a web service method) Individually, I have no problems in creating a grid view based upon the final product that the user selects i.e. Configure Data Source, amend the where clause so that the source picks up from the one control. My problem lies in that I would like to set up a condition whereby the grid view is populated according to whether either the ddl is populated OR the acTextBox is populated OR the textbox is filled with an ID. My thinking was to assign a related check box to each of the controls and depending upon which option is check, a button could be used to bring up the appropriate grid view results. What do people think? Is that the best way to do this and if so, how would I go about configuring the datasource to pick up the appropriate data value based upon the check box?
Posted: Nov 20, 2009 04:07 PM
View 3 Replies!
View Related
Forms Data Controls :: How To Change GridView Row Color When A GridView Row Is Selected
When an application user selects a particular row in my GridView, I would like to have the row highlighted in a different color. (By selects I mean the mouse cursor was moved into a cell in a GridView row) I found this article on the web where something similar is done. Basically the row color changes when the mouse cursor hovers over a GridView row. And again changes when the mouse cursor hovers over a different row. http://www.aspdotnetfaq.com/Faq/How-to-correctly-highlight-GridView-rows-on-Mouse-Hover-in-ASP-NET.aspx The difference with my approach is that I only want the color to change when a mouse cursor is placed in a gridview cell in a row. And then it won't change color until the cursor is placed in a different row/cell of the GridView. how I can have the row color change only when the row is selected? I tried using the onclick property but that did not work. (See lines 9 and 15 below) e.Row.Attributes.Add("onclick" 1 protected void Gridview1_RowCreated(object sender, GridViewRowEventArgs e) 2 { 3 // only apply changes if its DataRow [code]...
Posted: Nov 05, 2009 02:00 PM
View 2 Replies!
View Related
Change The Color Of Particular Cell In A Gridview?
Iam displaying the days of a month in a grid. If the first day of the month starts with Wednesday then I need to gray out the cells of Monday and Tuesday for the first week. Is it possible to change the color of particular cell in a gridview? Iam not using rowdatabound Is there any alternative apart from rowdatabound?
Posted: Jul 21 10 at 11:17
View 2 Replies!
View Related
Change Color Of Certain Texts In A Gridview?
I have a gridview that displays data from a DB... Currently I can only change colors of all the texts in a cell, but what I need to do is to change the color of certain texts only. Is there a way to do this? This is my function for changing color of texts in cells: protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (_SearchKey != string.Empty) { if (e.Row.RowType == DataControlRowType.DataRow) { for (int ctr = 0; ctr < e.Row.Cells.Count; ctr++) { if (e.Row.Cells[ctr].Text.ToLower().Contains(_SearchKey.ToLower())) { e.Row.Cells[ctr].ForeColor = System.Drawing.Color.Red; } } } } }
Posted: Feb 23 10 at 3:38
View 1 Replies!
View Related
Forms Data Controls :: Binding Data With Gridview Based Upon Condition?
I have a Data Table which Populate from the Stored Procedure which is below [Code].... and iam binding the Gridview with Data Table it is working .Now i have to make some thing visible and Invisible based upon some Value like below Datatable dtTable = (Viewstate)["StatusData"]; // Same Data Table which is Data Source of Gridview Control [Code].... Where Status.Open is an integer Enum value like Open = 1 and Close = 2 .row["Status"] is the Text Open and i want to compare with integer valueHow i compare the Values ? i have to use the same Data table or not?
Posted: Jan 22, 2010 11:35 AM
View 2 Replies!
View Related
Change Gridview Cell Color At Runtime?
Tried this: Code: Protected Sub gvCriticalMaterials_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvCriticalMaterials.RowCreated If e.Row.RowType = DataControlRowType.DataRow Then If Trim(e.Row.Cells(7).Text) <> "" And Trim(e.Row.Cells(10).Text) <> "" Then If Convert.ToDateTime(e.Row.Cells(7).Text) < Convert.ToDateTime(e.Row.Cells(10).Text) Then e.Row.Cells(7).ForeColor = Drawing.Color.Red End If End If End If End Sub But it never shows any value for text in the cells.
Posted: Jan 27th, 2011, 12:09 PM
View 3 Replies!
View Related
Gridview - Change The Color Properties Vertically?
I have a dynamic gridview, about 35 rows by 11 columns. When the user hovers over a row, I highlight the row's background in green (with CSS:Hover). I would like to change the column's background as well, but I don't think I can assign css to a entire column. How can I accomplish this?
Posted: Mar 19 at 1:50
View 1 Replies!
View Related
Forms Data Controls :: Change Row Color In Gridview?
I have a grid view where I need to change the row back color based on a ID. The girdview is bound dynamically and it can have any sets of ID. So when two ID are the same the backcolor of the row needs to be the same. I know I should change the Rowdatabound code but I am not sure how to dynamically change the color. Is there a way to increment color values based on ID's
Posted: Oct 06, 2009 04:56 PM
View 5 Replies!
View Related
Forms Data Controls :: How To Change Row Color In GridView
I am developing a scheduling system in which customers are alloted 15 minute timeslots (see example below). During rowdatabound event I know how to change the value of Cell(1) to NULL by using e.Row.Cells(1).Text = "" so Select option is not available for that timeslot. This works fine for someone who has taken only 1 timeslot. Question is, when a Customer has for example 1:00 hour appointment (which is 4 x 15 minute time slots), how do I make the next 3 rows Cell(1) value NULL? Is there anything like e.Row+1.Cells(1).Text = "" or some loop that I can run to take care of next few rows? [code]....
Posted: Feb 25, 2010 04:01 AM
View 4 Replies!
View Related
Forms Data Controls :: GridView Row Color Change
I have alternative colors on my gridview white and lightiest green when i am placing mouse over the row color changed to Green when i mouse out of the row color changed to white i did write.Here i need a change when event mouseout occures rows-color fallsbackto original alternative colors i.e white and lightiest green Private Sub GVData_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVData.RowCreated If e.Row.RowType = DataControlRowType.DataRow Then e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor = 'lightgreen';this.style.cursor='hand'") [code]....
Posted: Dec 31, 2009 08:12 AM
View 6 Replies!
View Related
Forms Data Controls :: Change Value's Color By Sql In GridView?
I am retrive data from sql servr (2000) and then binding with GridView. Select Colorname,case when 'red' then '<font color=red>*</font>' When 'green' then '<font color=red>*</font>' end as refernce from colorset. I was expect the gridvew will show difference kind of color in column reference.. But it doesn't... which just shows (assume this is my GridView) Color name | reference Red | <font color=red>*</font> Green | <font color=green>*</font> I want to show Color name | reference Red | * // show a red star Green | * // show a green star
Posted: Oct 06, 2009 11:06 AM
View 7 Replies!
View Related
Web Forms :: How To Change The Background Color Of A Css Class By Passing A Color Retrieved From A SQL String
I am doing all of the css and theming for our project, and am trying to create an automatic theming convention. All of the buttons on the site will be using the same css class from the style sheet page. The problem I am having is that the color behind the button depends on the users color in the database. I pull their color from the database and theme the site accordingly. My question is how can I change the color behind a button, in this case a div object, and set it when the page loads. I know I can set the color on the client's side, but that is only based on the name of the object. Since the buttons are all on different pages, I will not know the name of the button I am using. I am using a Masterpage also. In the css class I have a class named .buttonBackground. I have a png image set to this button (I say button, but its a div object). I need to be able to change the background color of this image to the color from the DB when the page loads. I thought it would be fairly simple but realized that I do not know the name of the buttons on the current page. I can change the color onmouseover and onmouseout with JS, but have no idea how to set the color initially.
Posted: Nov 17, 2009 02:13 AM
View 2 Replies!
View Related
Forms Data Controls :: Change Color On Row In Gridview Using Event?
I am trying to change the backgound color on a datarow in a gridview while it is being built by using an event in the properties of the gridview. I found an example for an integer check but the field I want to check is a text field with the words "STANDARD" OR "SIGNIFICANT" stored in the field within the database. Here is the code I am executing below but I get the error below. (I am including the code I found that does the integer check at the bottom so you can see it as well). Error 5 Overload resolution failed because no accessible '=' can be called with these arguments: 'Public Shared Operator =(a As String, b As String) As Boolean': Value of type '1-dimensional array of Object' cannot be converted to 'String'. [Code].... [Code].... [Code]....
Posted: Nov 07, 2009 04:48 PM
View 3 Replies!
View Related
Forms Data Controls :: How To Change GridView Row Color On Mouse Over
I am trying to create a Mouse Over for my GridView and have a problem hope any of you can shed some light to how to fix it Currently my Alternate GridView Row is using this CSS style with an image .mGrid .alt {background: [code].... In my GridView I have some codes below, when my mouse move over the Alternate Row I would like to replace the image I defined in my css stylesheet with a color but it doesn't work Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound If True Then If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowState = DataControlRowState.Alternate Then e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='lightblue'") e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='transparent'") Else e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='lightblue'") e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white'") End If End If End If I need to somehow replace the AlternateRowStyle with this.style.backgroundColor of my choice.
Posted: Nov 11, 2009 02:51 PM
View 5 Replies!
View Related
Forms Data Controls :: Change Font Color On Gridview?
i got a gridview to show some records from a database in sql server, two fields in that database are priority and status. So i want to change the font color in the gridview to those fields. for example, when the priority is high, show high with font red and when status is new use bond font .
Posted: Oct 22, 2009 09:30 PM
View 6 Replies!
View Related
Forms Data Controls :: Unable To Change Row Item Color In GridView
I want to change row items colour if last column value of each row >72 therefore I used following code: [Code].... The above code is working fine but when I am trying to control row items to the generlized method by the following code, it is working fine but the procedure is not applying successfully for one row which is also meeting criteria: [Code]....
Posted: Mar 04, 2010 07:02 AM
View 7 Replies!
View Related
|