|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Need to Format a zipcode into xxxxx-xxxx.I guess that you can't do this with the property window
of datagrid control. Probably need an itemdatabound event. How can I program an itemdatabound control to get a column (Zipcode) to look as such xxxxx-xxxx. It currently is in this format, xxxxxxxxx. Thanks for any help. .. Jeff,
It happens that the string formatting is the only part that does work for me. My problem is changing the cell background color, as in my previous post. This FormatCells method works for me if it is called by the DataGrid1_ItemDataBound event handler. The format specifier may be a little off, but the code certainly executes before the grid displays. ' The ItemDataBound event is handled for each row in datasource...... Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound ' FormatCells does get called for each row..... FormatCells(sender, e) End Sub Protected Sub FormatCells(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then e.Item.Cells(5).Text = String.Format("ddddd-dddd", zip) Show quoteHide quote "Jeff Thur" <j***@emscirc.com> wrote in message news:021701c51553$6b75d380$a501280a@phx.gbl... > I guess that you can't do this with the property window > of datagrid control. Probably need an itemdatabound event. > > How can I program an itemdatabound control to get a column > (Zipcode) to look as such xxxxx-xxxx. It currently is in > this format, xxxxxxxxx. > Thanks for any help. > . > >
Adding "delete" functionality in DataGrid - without a ButtonColumn
Add additional row into header? bound columns of a datagrid How To Insert ASP.NET User Control into DataGrid Column? Adding CSS to LinkButton Add header text dynamically in a datagrid with templatecolumns? Datagrid colum has no Dataformat property Printer-Friendly DataGrid option How to set cell background based on cell value when datagrid is displayed Can we put ActiveX Control into the DataGrid Column? |
|||||||||||||||||||||||