Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions C#/GridView-單列雙列顏色不同.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex != -1)
{

//�۰��ܦ����
if (e.Row.RowIndex % 2 == 1)
{
//��Ƹ�ƦC
e.Row.Style.Add(HtmlTextWriterStyle.BackgroundColor, "#FFFFFF");
e.Row.Attributes.Add("onmouseout", "onmouseChangeRowColor(this,true,false);");
e.Row.Attributes.Add("onmouseover", "onmouseChangeRowColor(this,true,true);");
}
else
{
//���Ƹ�ƦC
e.Row.Style.Add(HtmlTextWriterStyle.BackgroundColor, "#EFF3FB");
e.Row.Attributes.Add("onmouseout", "onmouseChangeRowColor(this,false,false);");
e.Row.Attributes.Add("onmouseover", "onmouseChangeRowColor(this,false,true);");
}
}
}
62 changes: 62 additions & 0 deletions C#/GridView-樣板.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
���Vô�� Bind()
��Vô�� Eval()


[textbox]
1.add template col
2.edit template : ��textbox
3.�btextbox binding : DataBinder.Eval(Container, "DataItem.�޽L�H")

[checkbox]
1.add template col
2.edit template : ��check
3.�bcheck.checked set (Eval("chk2").ToString()=="1")

[�ק�-c1webgrid]

1.add template col
2.edit template : ��LinkButton
3.set commandName
4.
this.C1WebGridList.DeleteCommand += new C1.Web.C1WebGrid.C1CommandEventHandler(this.C1WebGridList_DeleteCommand);
private void C1WebGridList_DeleteCommand(object source, C1.Web.C1WebGrid.C1CommandEventArgs e)
{
.............................
}

[�ק�-Gridview]
1.add template col
2.edit template : ��LinkButton
3.set commandName
4.�{���X

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridView tmp = GridView1;// (GridView)source;
int pk_key = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;

string sID = tmp.Rows[pk_key].Cells[2].Text.Trim();
Response.Redirect("data_input_modify.aspx?mode=insert&input_id=" + sID );
}

QA �p��viisble=false��cell��
���i�H����visible=false�A�nbind���Avisible
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header || e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[2].Visible = false;//�n������
}
}

https://dotblogs.com.tw/eason.yen/2011/01/31/21164


[�R��]







Binary file added C#/GridView使用方法.docx
Binary file not shown.
Binary file added C#/ReportView使用方法.docx
Binary file not shown.
Binary file added C#/TreeView的使用方式.docx
Binary file not shown.
39 changes: 39 additions & 0 deletions C#/gridview-merge.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
protected void GridView1_PreRender(object sender, EventArgs e)
{
if (isSearch == false) return;
isSearch = false;

foreach (GridViewRow gvR in this.GridView1.Rows)
{
for (int i = gvR.DataItemIndex + 1; i < this.GridView1.Rows.Count; i++)
{
//�P�U�@�C���Ȭ۵�;
if (this.GridView1.Rows[i].Cells[1].Text.Trim() != " ")
{
if (gvR.Cells[1].Text.Trim() == this.GridView1.Rows[i].Cells[1].Text.Trim())
{
gvR.Cells[1].RowSpan = gvR.Cells[1].RowSpan == 0 ? gvR.Cells[1].RowSpan = 2 : gvR.Cells[1].RowSpan += 1;
this.GridView1.Rows[i].Cells[1].Visible = false;
}
else
{
break;
}
}
}

for (int i = gvR.DataItemIndex + 1; i < this.GridView1.Rows.Count; i++)
{
//�P�U�@�C���Ȭ۵�;
if (gvR.Cells[0].Text.Trim() == this.GridView1.Rows[i].Cells[0].Text.Trim())
{
gvR.Cells[0].RowSpan = gvR.Cells[0].RowSpan == 0 ? gvR.Cells[0].RowSpan = 2 : gvR.Cells[0].RowSpan += 1;
this.GridView1.Rows[i].Cells[0].Visible = false;
}
else
{
break;
}
}
}
}
95 changes: 95 additions & 0 deletions C#/reader.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
https://msdn.microsoft.com/zh-tw/library/haa3afyz(v=vs.110).aspx

�ݭn�^���j�q��ƮɡADataReader �O��������ܡA�]����Ƥ��|�֨��ܰO����C

�Χ� DataReader �����A�аȥ��I�s Close ��k�C
�p�G�z�� Command �]�t��X�ѼƩζǦ^�ȡA�h�������� DataReader ������~��ϥΥ��̡C
�Ъ`�N�ADataReader �}�Ҵ����AConnection �u��Ѹ� DataReader �ϥΡC ���������l DataReader ������A�~����� Connection ������R�O�A�]�A�إߨ�L DataReader�C
==================
if (reader.HasRows)
while (reader.Read())
reader.GetValue(1)
reader.Close();
======================================
string cn = " Provider=SAOLEDB;Data Source=DW_IQ_NEW ";

System.Data.OleDb.OleDbConnection con = null;
con = new System.Data.OleDb.OleDbConnection(cn);

con.Open();
System.Data.OleDb.OleDbCommand command = con.CreateCommand();

command.CommandText = @"Select top 10 * from TRADETOOL_FEE";

System.Data.OleDb.OleDbDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
laCount1.Text += string.Format("{0}\t{1}\t{2}\t{3}\t{4} ", reader.GetValue(0), reader.GetValue(1), reader.GetValue(2), reader.GetValue(3), reader.GetValue(4));

//Console.WriteLine("{0}\t{1}", reader.GetString(0), reader.GetString(1));
}
}
reader.Close();

======================================
�U�C�{���X�d�Ҧb DataReader ���󤤭��ơA�ñq�C�Ӹ�ƦC�Ǧ^��Ӹ�Ʀ�C
C#
static void HasRows(SqlConnection connection)
{
using (connection)
{
SqlCommand command = new SqlCommand(
"SELECT CategoryID, CategoryName FROM Categories;",
connection);
connection.Open();

SqlDataReader reader = command.ExecuteReader();

if (reader.HasRows)
{
while (reader.Read())
{
Console.WriteLine("{0}\t{1}", reader.GetInt32(0),
reader.GetString(1));
}
}
else
{
Console.WriteLine("No rows found.");
}
reader.Close();
}
}

====================
�ϥ� NextResult ���^���h�ӵ��G��
�p�G�Ǧ^�h�ӵ��G���ADataReader �|���� NextResult ��k�̧Ǧb���G�������ơC �U�C�d����� SqlDataReader �ϥ� ExecuteReader ��k�A�B�z��� SELECT ���z�������G�C
C#VB
static void RetrieveMultipleResults(SqlConnection connection)
{
using (connection)
{
SqlCommand command = new SqlCommand(
"SELECT CategoryID, CategoryName FROM dbo.Categories;" +
"SELECT EmployeeID, LastName FROM dbo.Employees",
connection);
connection.Open();

SqlDataReader reader = command.ExecuteReader();

while (reader.HasRows)
{
Console.WriteLine("\t{0}\t{1}", reader.GetName(0),
reader.GetName(1));

while (reader.Read())
{
Console.WriteLine("\t{0}\t{1}", reader.GetInt32(0),
reader.GetString(1));
}
reader.NextResult();
}
}
}