如何在asp.net datagrid值中添加分隔的逗号 [英] how to add separated comma in asp.net datagrid values
本文介绍了如何在asp.net datagrid值中添加分隔的逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在asp.net datagrid值中添加分隔的逗号?
这是我的绑定方法,我需要用一个分开的comma.how绑定一个Amount来做到了吗?
how to add separated comma in asp.net datagrid values??
This is my bind method,i need to bind a Amount with separated comma.how to do it??
if (Session["dt1"] != null) dt1 = (DataTable)Session["dt1"];
DataRow dr = dt1.NewRow();
dr["CusName"] = Label5.Text.Trim().ToString();//1
dr["REP"] = Label6.Text.Trim().ToString();//2
//Ageing
DateTime dt = Convert.ToDateTime("2013-12-31 12:00:00.0000000"); //mm/dd/yyyy
DateTime dt2 = Convert.ToDateTime(txtfromdate.Text);//mm/dd/yyyy
TimeSpan ts = dt.Subtract(dt2);
dr["AGEING"] = ts.Days.ToString();//3
dr["DATE"] = txtfromdate.Text;//5
dr["NUM"] = txtpaymentDetails0.Text;//6
dr["AMOUNT"] = Double.Parse(txtamount.Text); //7
dt1.Rows.Add(dr);
Cusinvoicegrid.DataSource = dt1;
Cusinvoicegrid.DataBind();
推荐答案
试试这个,但你必须先验证它是一个数字。
Try this, but you have to validate that it is a number first.
string str =txtamount.Text;
dr["AMOUNT"] = (string.Format("{0:C}", Convert.ToDecimal(str))).Substring(1);
这篇关于如何在asp.net datagrid值中添加分隔的逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文