Forms Data Controls :: Gridview Column Formatting Depending On Text In Header?
Mar 30, 2010
I want if the header of a particular column contains a word "S", the header and row turns red. I used following code to make header red and it works fine. How to make it such that the rows also turn red if condition is met ? I cannot hardcode in columns since the Gridview is autogenerate colums as data structure keeps changing.
Protected Sub GridView1_DataBound(ByVal sender
As System.EventArgs)Dim HeaderRow
As GridViewRow = GridView1.HeaderRowFor
In HeaderRow.CellsIf c.Text.EndsWith("S")
c.BackColor = Drawing.Color.OrangeRed
I have a merged column of firstname and lastname by "Select firstname + lastname from table" but when it appears in the gridview the header text of the column is "Expr1000". How can I change the header text of that merged column?, and I want to change its text into "NAME".
HUsing C# to develop a web application. Have a gridview to display data from the a sql table.The headers of the gridview is achieve using a table. Need to format the header cells to align with the columns of the gridview.Currently I'm using a trial an error method to set the width of the header to align with the gridview columns. Can I align the Table header to concide with the gird view column width progarmatically?
I have a Gridview with certain columns header in form of dates (coz the datasource is with column field from a date field in a cross tab query). What will be the code of databound event that convert col labels from like 6/1/2010 to Jun-10 in the header text.
I was wondering if anyone could help me. I have a template field which has four itemtemplates that each hold a label in a gridview. These labels are always constant with the same strings. What I want to do is change the css formatting of these four labels depending on the value of a column. So the css formatting would have to be done for each row, not the whole column. I bind the gridview to a dataaccesslayer so there is no sqldatasource on the page. Does anyone have any idea how to do this and where it would be done. I will have the dataview with the data sorted in the correct order. The actual column that is used to alter the CSS will not be in the gridview although I could assign it to the datakeyname if that makes it easier as the data is not sensitive.
i have a gridview bound to sql datasource with template fields binding the columns. I have set the Header Style to a css class. I have 3 columns not bound to data as Add, Edit and Delete. When I set the text color to white for the header only the non bound columns go white. The bound columns are BLUE like hyperlink. Any one know a way round this. (If I set the style in the gridview the all columns are white. Want to set in external css file).
I have an asp.net gridview which represents some kind of reservation calendar. Each row represents a workplace and each column a day. The header value (date) is set by a method since the start of the time period shown by the gridview can be selected by the user. Since the date column can start at every day of the week I wanted to mark the weekend day columns with a special background. How to set this? (See .aspx code snippet below which is currently used for each column ().
Remark: ItemStyle-BackColor= '<%# %>' (dynamic) annotation isn't allowed in the <TemplateField> Tag and the actual date must be evaluated somehow from the header or another control.
I have a page with a TextBox, a Button, a GridView, and a SqlDataSource. I click the Button to execute the SQL in the TextBox using the SqlDataSource. The SqlDataSource populates the GridView. Everything works as expected until I click a column heading to sort.
When I click a column heading, the GridView disappears and I have to click the Button to display the grid again. When I do, the grid is displayed in the order of the column I clicked.
I don't understand why the GridView is disappearing when I click a column header.
Does anyone know how to fix this so the GridView is sorted and displayed only by clicking the column header?
I want to fill a gridview with data from a database table..But, I have to avoid the column names from the database..I had already specified header text for the gridview.. i had already selected two column names 'name' and 'number' from a database table, then I had created two columns for the gridview( with header text's name and number)..Now i want to select the all the data from columns 'name' and 'number'..and then fill the respective columns.