Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. Data;
Using System. Collections;
Using System. Drawing;
Public partial class PackingInfo: System. Web. UI. Page
{
ReportsManager rm = new ReportsManager ();
// Set the number of lines displayed on each page
Int TotalRowCount = 12;
// Number of automatically filled rows
Int numCount = 0;
Protected void Page_Load (object sender, EventArgs e)
{
If (! Page. IsPostBack)
{
This.txt CartonQty. Focus ();
ViewState ["SortOrder"] = "ctn no ";
ViewState ["OrderDire"] = "ASC ";
}
}
DataTable dt = new DataTable ();
String CartonSN = string. Empty;
String _ CartonSN = string. Empty;
// Calculate the data, which can be obtained from the database by modifying the data here
ICollection CreateDataSource (int RowsCount)
{
System. Data. DataTable dt = new System. Data. DataTable ();
System. Data. DataRow dr;
Dt. Columns. Add (new System. Data. DataColumn ("P/N", typeof (System. String )));
Dt. Columns. Add (new System. Data. DataColumn ("ctn no", typeof (System. String )));
Dt. Columns. Add (new System. Data. DataColumn ("CustomerSN", typeof (System. Decimal )));
For (int I = 0; I <RowsCount; I ++)
{
Dr = dt. NewRow ();
Dt. Rows. Add (dr );
}
System. Data. DataView dv = new System. Data. DataView (dt );
Return dv;
}
Protected void gv_RowDataBound (object sender, GridViewRowEventArgs e)
{
If (e. Row. RowType = DataControlRowType. DataRow)
{
E. Row. Cells [3]. Attributes. Add ("style", "vnd. ms-excel.numberformat :@");
}
Int m;
For (m = 0; m <gv. Rows. Count; m ++)
{
If (e. Row. RowType = DataControlRowType. DataRow)
{
E. Row. Attributes. Add ("onmouseover", "c = this. style. backgroundColor, this. style. backgroundColor = '# 00A9FF '");
E. Row. Attributes. Add ("onmouseout", "this. style. backgroundColor = c ");
}
}
Try
{
If (e. Row. RowType = DataControlRowType. DataRow)
{
// Calculate the number of automatically filled rows
NumCount ++;
}
If (e. Row. RowType = DataControlRowType. Footer)
{
// Add the missing row here
Int toLeft = TotalRowCount-numCount;
Int numCols = gv. Rows [0]. Cells. Count;
For (int I = 0; I <toLeft; I ++)
{
GridViewRow row = new GridViewRow (-1,-1, DataControlRowType. EmptyDataRow, DataControlRowState. Normal );
For (int j = 0; j <numCols; j ++)
{
TableCell cell = new TableCell ();
Cell. Text = "";
Row. Cells. Add (cell );
}
Gv. Controls [0]. Controls. AddAt (numCount + 1 + I, row );
}
}
}
Catch (Exception ex)
{
This. lblMessage. Text = ex. Message;
This. lblMessage. ForeColor = Color. Red;
}
If (e. Row. RowIndex! =-1)
{
Int id = e. Row. RowIndex + 1;
E. Row. Cells [0]. Text = id. ToString ();
}
}
}
Allen Chen's column