when I get the value from the database, if the database value is "999999", the TextBox will display null; if the database value is "456", then the TextBox will display 4.56".
That is the function:
Code:
public static string TotalBaselineMaximum(string MaximumAMT)
{
string tmpMaximumAMT = "";
if (MaximumAMT == "")
tmpMaximumAMT = "999999";
else if (MaximumAMT == "999999" || MaximumAMT == "0")
tmpMaximumAMT = "";
else
{
decimal dec;
dec = Convert.ToDecimal(MaximumAMT);
if (MaximumAMT.Contains("."))
tmpMaximumAMT = Math.Round(dec * 100).ToString();
else
tmpMaximumAMT = (dec / 100).ToString();
}
return tmpMaximumAMT;
}
protected void OnClick_lbtnBack(object sender, EventArgs e)
{
string requestPage = Session["CAABackToPreviousPage"].ToString();
Response.Redirect(requestPage, true);
}
protected void OnClick_btnExport(object sender, EventArgs e)
{
//Export the GridView to Excel
//PrepareGridViewForExport(GridView1);
ExportGridView();
}
private void ExportGridView()
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=ContestWinnerReport.csv");
Response.Charset = "";
Response.ContentType = "application/text";
//GridView1.AllowPaging = false;
//GridView1.DataBind();
StringBuilder sb = new StringBuilder();
for (int k = 0; k < GridView1.Columns.Count; k++)
{
//add separator
sb.Append(GridView1.Columns[k].HeaderText + ',');
}
//append new line
sb.Append("\r\n");
int testint = GridView1.Rows.Count;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
for (int k = 0; k < GridView1.Columns.Count; k++)
{
//add separator
if (k == 2)
sb.Append("'" + GridView1.Rows[i].Cells[k].Text + ',');
else
sb.Append(GridView1.Rows[i].Cells[k].Text + ',');
}
//append new line
sb.Append("\r\n");
}
Response.Output.Write(sb.ToString());
Response.Flush();
Response.End();
////GridView1.DataSource = Cache["ContestList"];
////GridView1.DataBind();
//GridView1.HeaderStyle.ForeColor = System.Drawing.Color.Black;
//string attachment = "attachment; filename=ContestWinnerReport.xls";
//Response.ClearContent();
//Response.AddHeader("content-disposition", attachment);
//Response.ContentType = "application/ms-excel";
////Response.ContentType = "application/text";
//StringWriter sw = new StringWriter();
//HtmlTextWriter htw = new HtmlTextWriter(sw);
//GridView1.RenderControl(htw);
//Response.Write(sw.ToString());
//Response.End();
//string attachment = "attachment; filename=Contacts.xls";
//Response.ClearContent();
//Response.AddHeader("content-disposition", attachment);
//Response.ContentType = "application/ms-excel";
//StringWriter sw = new StringWriter();
//HtmlTextWriter htw = new HtmlTextWriter(sw);
//// Create a form to contain the grid
//HtmlForm frm = new HtmlForm();
//GridView1.Parent.Controls.Add(frm);
//frm.Attributes["runat"] = "server";
//frm.Controls.Add(GridView1);
//frm.RenderControl(htw);
////GridView1.RenderControl(htw);
//Response.Write(sw.ToString());
//Response.End();
}
private void PrepareGridViewForExport(Control gv)
{
LinkButton lb = new LinkButton();
Literal l = new Literal();
string name = String.Empty;
for (int i = 0; i < gv.Controls.Count; i++)
{
if (gv.Controls[i].GetType() == typeof(LinkButton))
{
l.Text = (gv.Controls[i] as LinkButton).Text;
gv.Controls.Remove(gv.Controls[i]);
gv.Controls.AddAt(i, l);
}
else if (gv.Controls[i].GetType() == typeof(DropDownList))
{
l.Text = (gv.Controls[i] as DropDownList).SelectedItem.Text;
gv.Controls.Remove(gv.Controls[i]);
gv.Controls.AddAt(i, l);
}
else if (gv.Controls[i].GetType() == typeof(CheckBox))
{
l.Text = (gv.Controls[i] as CheckBox).Checked ? "True" : "False";
gv.Controls.Remove(gv.Controls[i]);
gv.Controls.AddAt(i, l);
}
if (gv.Controls[i].HasControls())
{
PrepareGridViewForExport(gv.Controls[i]);
}
}
}
static string ExtractNumbers(string expr)
{
return string.Join(null, System.Text.RegularExpressions.Regex.Split(expr, "[^\\d]"));
}
// Unary operator overloading
// Author: rajeshvs@msn.com
using System;
class Complex
{
private int x;
private int y;
public Complex()
{
}
public Complex(int i, int j)
{
x = i;
y = j;
}
public void ShowXY()
{
Console.WriteLine("”{0} {1}”", x, y);
}
public static Complex operator -(Complex c)
{
Complex temp = new Complex();
temp.x = -c.x;
temp.y = -c.y;
return temp;
}
}
class MyClient
{
public static void Main()
{
Complex c1 = new Complex(10, 20);
c1.ShowXY(); // displays 10 & 20
Complex c2 = new Complex();
c2.ShowXY(); // displays 0 & 0
c2 = -c1;
c2.ShowXY(); // diapls -10 & -20
}
}
using System;
class Complex
{
private int x;
private int y;
public Complex()
{
}
public Complex(int i, int j)
{
x = i;
y = j;
}
public void ShowXY()
{
Console.WriteLine("”{0} {1}”", x, y);
}
public static Complex operator +(Complex c1, Complex c2)
{
Complex temp = new Complex();
temp.x = c1.x + c2.x;
temp.y = c1.y + c2.y;
return temp;
}
}
class MyClient
{
public static void Main()
{
Complex c1 = new Complex(10, 20);
c1.ShowXY(); // displays 10 & 20
Complex c2 = new Complex(20, 30);
c2.ShowXY(); // displays 20 & 30
Complex c3 = new Complex();
c3 = c1 + c2;
c3.ShowXY(); // dislplays 30 & 50
Console.ReadKey();
}
}
protected void saveDataPsm(string fn, string url, string path2)
{
string sFileName = "c:\\Files\\test.txt";
//string sFileName = "c:\\Files\\test.txt";
WebClient myWebClient = new WebClient();
byte[] myDataBuffer = myWebClient.DownloadData(url);
using (FileStream fsNew = new FileStream(fn, FileMode.Create, FileAccess.Write))
{
fsNew.Write(myDataBuffer, 0, myDataBuffer.Length);
}
}