Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid Cell Formatting

Status
Not open for further replies.

SSesham

Programmer
Feb 26, 2004
17
US
I need help formatting a column while displaying in a cell of a datagrid. The data will looklike 120:80. I need the user to see the cell as " : ".
I'm using the DataGrid1_ItemDataBound event to format all my cells.

to be precise

If e.Item.Cells[17].Text is my cell and want to display in the datagrid as " : " what will be the format string for this cell in DataGrid1_ItemDataBound event?

Thanks for your time in advance..
 
what type of data does the column contain?

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
The data is string data eg., 160:80
and i need the : to appear in the middle of 2 numbers in the cell and also want to save it! its like we are formatting the cell for user and while saving it i'll take the content of the whole cell and post it to the database (including the ':')
 
hmm... if you want this at client side then you need something like a mask input field

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Assuming that each number (string) is coming from a different database field, why not just handle it with a template?
Code:
<asp: TemplateColumn HeaderText="Your Header">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,"db_field_1")%>[COLOR=red yellow]:[/color]<%# DataBinder.Eval(Container.DataItem,"db_field_2")%>
</ItemTemplate>
</asp: TemplateColumn>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top