https://pramaire.pixnet.net/blog/post/31837470
using System;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;
namespace prjGridV
{
public partial class _default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
conn.ConnectionString = WebConfigurationManager.ConnectionStrings["dbconn"].ConnectionString;
conn.Open();
cmd.Connection = conn;
cmd.CommandText = "SELECT [U_NAME],[U_LEVEL] FROM [AMS00].[dbo].[UNIT] order by [U_LEVEL]";
//cmd.Parameters.Clear();
//cmd.Parameters.AddWithValue("",);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
conn.Close();
//string dr_U_NAME = "無任何資料1";
//string dr_U_LEVE = "無任何資料2";
//==========================================
//if (dt.Rows.Count>0)
//{
// dr_U_NAME = "";
// dr_U_LEVE = "";
// foreach (DataRow dr_data in dt.Rows)
// {
// dr_U_NAME += dr_data["U_NAME"].ToString();
// dr_U_NAME += "<br />";
// dr_U_LEVE += dr_data["U_LEVEL"].ToString();
// dr_U_LEVE += "<br />";
// }
//}
//Literal1.Text = dr_U_LEVE;
//Literal2.Text = dr_U_NAME;
//==========================================
//事後加一筆=====================================
//DataRow dr = dt.NewRow();
//dr["U_NAME"] = "千機";
//dr["U_LEVEL"] = 9;
//dt.Rows.Add(dr);
//==============================================
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void Button2_Click(object sender, EventArgs e)
{
TableRow row = new TableRow();
TableCell cell1 = new TableCell();
cell1.Text = "表格第一列";
row.Cells.Add(cell1);
TableCell cell2 = new TableCell();
cell2.Text = "表格第二列";
//cell2.Font.Size = FontUnit.Large; //設定文字尺寸
cell2.ForeColor = System.Drawing.Color.Blue; //設定文字顏色
cell2.BackColor = System.Drawing.Color.Red; //設定文字顏色
row.Cells.Add(cell2);
TableCell cell3 = new TableCell();
cell3.Text = "表格第三列";
row.Cells.Add(cell3);
//產生表格
Table1.Rows.Add(row);
}
protected void GridView1_PreRender(object sender, EventArgs e)
{
int i = 1;
foreach (GridViewRow gvItem in GridView1.Rows)
{
if (gvItem.RowIndex != 0)
{
//比對如果名稱如果相同就合併(RowSpan+1)
if (gvItem.Cells[0].Text.Trim() == GridView1.Rows[(gvItem.RowIndex - i)].Cells[0].Text.Trim())
{
GridView1.Rows[(gvItem.RowIndex - i)].Cells[0].RowSpan += 1;
gvItem.Cells[0].Visible = false;
i = i + 1;
}
else
{
GridView1.Rows[(gvItem.RowIndex)].Cells[0].RowSpan += 1;
i = 1;
}
}
else
{
gvItem.Cells[0].RowSpan = 1;
}
}
}
}
}
2019年7月20日 星期六
訂閱:
張貼留言 (Atom)
WPF聊天室应用(ASP.NET Core SignalR)
WPF聊天室应用(ASP.NET Core SignalR) https://www.bilibili.com/video/BV1Q741187Si?p=2 https://www.bilibili.com/video/BV1UV411e75T?from=search&...
-
介面,依賴反轉,單元測試 https://www.youtube.com/watch?v=GpYieGx4y6M 介面隔離,反射,特性,依賴注入 https://www.youtube.com/watch?v=3bZ4rNS_o10
-
https://mgleon08.github.io/blog/2018/07/16/jwt/ https://medium.com/%E9%BA%A5%E5%85%8B%E7%9A%84%E5%8D%8A%E8%B7%AF%E5%87%BA%E5%AE%B6%E7%AD%86%...
-
https://dotblogs.com.tw/v6610688/2015/02/19/iis_office_access_word_excel_com_interop_api_configuration https://dotblogs.com.tw/gelis/archi...
沒有留言:
張貼留言