C# - Formatting Enum In Gridview?
Aug 31, 2010
i need to display the name of enum in gridview by data table returns its numeric value
i am using this for other columns
<asp:BoundField DataField="Name" HeaderText="User Name" />
i need to use it for enum to display the string value of enum Gender
<asp:BoundField DataField="Gender" HeaderText="Gender" />
View 1 Replies
Similar Messages:
Sep 28, 2010
whats wrong with this code, i try also Enum.Parse but didnt work.
public enum RoleNames
{
Administrator,
[code]...
View 1 Replies
Sep 24, 2010
I am trying to format a number in a GridView that is in in pounds into pence.e.g. 0.0106 to 1.06Is it possible to archive this with the DataFormatString on the GridView? Or would it make more sense to do the conversion within the stored procedure?
View 1 Replies
Feb 25, 2011
I want to add gridview dynamically with all formatting and with template fields ..
i m trying it by below way.
[code]....
but the problem is i m not able to assign datasource to gridview as i m not able to get object of gridview..
View 2 Replies
Feb 2, 2011
formatting a gridview where I have some numbers that show up with the minus sign on top of the number.Ideally I'd like to set the negative numbers to be red if you know how to do that.I'd also just like more control over the width of the columns.some of my formatting code is below. The If - Endif stuff fails with a null reference exception, but the forecolor and backcolor and align code works
[Code]....
View 4 Replies
Nov 19, 2010
Why does the gridview put everything in a table?! Is there a way to not have the gridview generate any html what-so-ever and just use what I have in the ItemTemplate?
View 1 Replies
Nov 2, 2010
I have a long text in SQL and passing it to a gridview. I am trying to make the gridview result display in a multiline scroll. I have tried the following code but to no avail. Additionally, the text in the gridview result is not in the same format as where it came from, eg. Word. That is the format such as bullet points and multiple spaces are removed. So what is left is a lenghty long string.
[code]....
View 2 Replies
Jun 3, 2010
I have the following VB code that is trying to change colors based on the values. The first condition works but the second does not.
[Code]....
View 3 Replies
Jun 14, 2010
I have the following code:
[Code]....
I need to add a check for a checkbox column in the grid. Something like:If CDate(e.Row.Cells(6).Text) < Date.Now and 'checkbox is checked' Then make another colorHow do I check for the value of the checkbox?
View 5 Replies
Mar 18, 2010
I'm trying to get numbers converted to the proper look I prefer. But, it doesn't seem to be working.
I'd like the number to read 1,092, but instead it's listing it as 1092.0000000
Below is my EVAL as well as the code behind for this.
For the eval, I had to add the Convert.ToString to handle DBNULL items.
[Code]....
View 6 Replies
Jan 21, 2010
I want to display a Gridview of Patients before I submit them to the database. Is there a way(better way), other then List<Patients>, to bind a list to a GridView.
I am using Linq to SQL and I have a DAL with the Patients table inside. I create a new list of Patients
[Code]....
Now the problem is I can't use a Linqdatasource or Objectdatasource to link to the GridView as no data is in the db yet. The only thing that works is GridView.DataSource = _patients; but I lose all automatic formatting and as far as I can tell it is going to be a pain to format manually. It would seem I should be able to somehow link my object _patients to an one of the datasourses so I would have formatting and all.
View 2 Replies
Feb 2, 2011
I have a gridview on my aspx page. I know we can format gridview row in rowdatabound() of gridview. But my problem is bit different.
In my gridview, i have a column customer code, a single code can repeat more than once successively. I want for one customer code, row color should be blue and as soon as code changes colour should be yellow for that code. Similarly when code changes again color should be blue again.
In this way color of my gridview rows should be blue and yellow alternately based on my customer code.I have arranged customer code in order by using sql order by clause.
View 2 Replies
Sep 22, 2010
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?
Here is my ASPX code
<div id="ProjectTableHeader" runat="server"
style="background-color: #993300; height: 40px; width: 300; margin: 0; padding: 0">
<table cellspacing="0" cellpadding="0" rules="all" border="1" id="tblHeader" style="font-family: Arial;font-size: 10pt; width:[code].....
View 4 Replies
Mar 26, 2011
I have the following code on a web page and would like to have the amount formatted as a currency value:
<ItemTemplate>
<%#
(Convert.ToDouble(Eval("Quantity"))
* Convert.ToDouble(Eval("UnitPrice")))%>
</ItemTemplate>
I have tried a number of things but nothing seems to work.
View 6 Replies
Feb 5, 2010
I am using a column named "bk_End_Date" in my gridview.I want to change the row color based on a condition.i.e. if the date value is within one week of today's date (upcomming days only), it's color should be red.I tried following method in RowDataBound Event of C#
//if (DateTime.Parse(e.Row.Cells[5].Text) <= DateTime.Today.AddDays(7))
//{
// e.Row.BackColor.Equals(Color.FromName("Red"));
[code]...
View 3 Replies
Mar 15, 2010
I've got a Gridview in which I have a column that shows percentages. I use the 0:P2 to format the percentage into readable format. However when the user 'edits' the particular row the percentage sign % still shows up in the textbox. When the user tries to save/update their change I throw an error on the % sign.
Is there a way to show the % only when the row isn't in an editable state?
[Code]....
View 2 Replies
Apr 30, 2010
I'm displaynig plain text in a Gridview and the format is not the one I'm looking for here's what's happening. The data in the database (SQL) is store as sample1
Sample 1:
Please do the following:
1. text here and more text
2. blah blah blah
3. more text, etc
However in the Grid view is displayed like this:
Sample 2:
Please do the following: 1. text here and more text 2. blah blah blah 3. more text, etc
How can I fotmatted it to llok like Sample 1 ??
Here's my code:
<Fields>
<asp:BoundField
DataField="Solutions"
HeaderText="Solutions"
ReadOnly="True" HtmlEncode="False"
ShowHeader="False"
SortExpression="Solutions">
<ItemStyle
BorderStyle="None"
VerticalAlign="Top"
Wrap="True"
/>
</asp:BoundField>
</Fields>
View 18 Replies
Jul 7, 2010
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.
View 1 Replies
Jan 26, 2010
specially VB code behind pages.I am writing an app with a colleague and I am stuck on something.he app is a holiday booking calendar. I have a gridview that shows the total number of days booked for each month of the year. When you click the cell for say January another gridview is populated below showing each day of january.My problem is that I want to change the formatting of the cells in the second gridview depending upon if any of the cells have a 1 or a 0.
View 3 Replies
May 17, 2010
I have a gridview populated by the code below:
[Code]....
This will create multiple fields in the gridview with some values.
Say i have this field called "Sold" and it has the value "1234.5600"
How can i display it like "1,234.56" ?
[Code]....
View 2 Replies
Feb 15, 2010
I am trying to format currency in a GridView cell so that a zero value displays blank, but otherwise the amount in currency is shown.
Is there a more simple way than this?
[Code]....
View 3 Replies
Jun 21, 2010
I have a Gridview and I want to format 2nd column of it to {0:dd-MMM-yy}
If it is not autogeneratedcolumn Gridview I would have used DataFormatString="{0:dd-MMM-yy}"
However, this time it is a autogeneratedcolumn Gridview so I cannot use the above code anymore.
So can I set that column format programmatically ?
I tried
GridView1.Columns(1).
But then there is nothing close to dataformat pops up from intellisense.
View 7 Replies
May 4, 2010
I have a Gridview which is autocolumngenerated so the column can be numeric or text depending on what the datasource returns.I want to format it such that :If the cell/column is numeric, then format it into sth like 3,331.How to write code to detect this and do the job ?
View 3 Replies
Mar 29, 2010
I have a Gridview with autogenerated columns since the query structure keeps changing depending the dropdown list.
However for Jan-10 etc column I want to format it to #,##0 etc. I use Dataformatstring when hard code the column but for autogenerated column, what can I do ?
I know one way is in script databound event make it that format whenever header = Jan-10 etc.
What should be the code?
View 2 Replies
Nov 1, 2010
I have parentGridView and childGridView. ChildGridView opens in ParentGridView cell. But it expands the cell and makes all the parents cells out of formatting look and feel.1 ) How can i use colspan property to expand the childGirdView? 2) i am using find control in codebehind, i dont want to disturb that hierarchy as well
View 4 Replies