ç¨.net å ä¸ä¸ªçäºè®¡ç®åè½
åå°ä»£ç ï¼
<html xmlns="http://www.w3.org//xhtml" >
<head runat="server">
<title>æ æ é¢é¡µ</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="type" HeaderText="åç§" />
<asp:BoundField DataField="create_date" HeaderText="å建æ¥æ" />
<asp:BoundField DataField="buy_sell" HeaderText="ä¹°(+)å(-)" />
<asp:BoundField DataField="create_price" HeaderText="建ä»ä»·" />
<asp:BoundField DataField="equal_date" HeaderText="å¹³ä»æ¥æ" />
<asp:BoundField DataField="equal_price" HeaderText="å¹³ä»ä»·" />
<asp:BoundField DataField="exchange_rate" HeaderText="æ±ç" />
<asp:BoundField DataField="poundage" HeaderText="æç»è´¹" />
<asp:BoundField DataField="rent" HeaderText="ä»ç§" />
<asp:TemplateField HeaderText="çäºå计">
<ItemTemplate>
<asp:Label ID="lblProfitLoss" Text='<%# (Decimal.Parse(Eval("equal_price").ToString()) - Decimal.Parse(Eval("create_price").ToString()))*Decimal.Parse(Eval("buy_sell").ToString())*Decimal.Parse(Eval("exchange_rate").ToString())-Decimal.Parse(Eval("poundage").ToString())-Decimal.Parse(Eval("rent").ToString()) %>' runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
åå°ä»£ç ï¼
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
getData();
}
}
private void getData()
{
//string strConn = "Data Source=.;Initial Catalog=db;Persist Security Info=True;User ID=sa;Password=sa";
SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["Conn"].ToString());
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
try
{
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("select * from tb_gold", conn);
da.Fill(ds);
if (ds != null)
{
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
}
catch
{
}
finally
{
if (conn.State != ConnectionState.Closed)
{
conn.Close();
}
}
}
æ°æ®è¡¨èæ¬ï¼
/
2024-11-30 20:21
2024-11-30 20:07
2024-11-30 20:05
2024-11-30 18:58
2024-11-30 18:28