CommandBor 代码如下:
protected override void Render(HtmlTextWriter writer)
{
//自定义按钮调用后台事件
#region
Table table = FpSpreadGV.FindControl("cmdTable") as Table;
TableCell cell1 = new TableCell();
Button btn1 = new Button();
btn1.ID = "btnSubmit";
btn1.Text = "提 交";
btn1.Width = 65;
btn1.Attributes.Add("class", "btn_2k3");
btn1.Attributes.Add("onclick", "return SubmitButtonClick()");
cell1.Controls.Add(btn1);
table.Rows[0].Cells.Add(cell1);
Button btn2 = new Button();
btn2.ID = "btnSave";
btn2.Text = "保存";
btn2.Width = 65;
btn2.Attributes.Add("class", "btn_2k3");
btn2.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(FpSpreadGV, "btnSave,-1,-1") + "; return false;");
cell1.Controls.Add(btn2);
table.Rows[0].Cells.Add(cell1);
Button btn3 = new Button();
btn3.ID = "btnEXCEL";
btn3.Text = "导出EXCEL";
btn3.Width = 80;
btn3.Attributes.Add("class", "btn_2k3");
btn3.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(FpSpreadGV, "btnEXCEL,-1,-1") + "; return false;");
cell1.Controls.Add(btn3);
table.Rows[0].Cells.Add(cell1);
Button btn4 = new Button();
btn4.Text = "返 回";
btn4.Width = 65;
btn4.Attributes.Add("class", "btn_2k3");
btn4.Attributes.Add("onclick", "return ReturnWin()");
cell1.Controls.Add(btn4);
table.Rows[0].Cells.Add(cell1);
#endregion
base.Render(writer);
}
分页代码是在数据绑定后做了下面2条语句的设置后 分页就现在在下一行了,如果不设置的话在一行显示的,只是分页没有页数显示:
FpSpreadGV.Pager.Mode = FarPoint.Web.Spread.PagerMode.Both;
FpSpreadGV.Pager.Position = FarPoint.Web.Spread.PagerPosition.Bottom;
数据显示全代码如下:
DataTable dt = GC_QuotePurDAL.GetSupplierPrice(strSql.ToString(), numTop);
if (dt != null && dt.Rows.Count > 0)
{
FpSpreadGV.DataSource = dt;
FpSpreadGV.DataBind();
FpSpreadGV.Sheets[0].Cells[0, 0, dt.Rows.Count - 1, 21].HorizontalAlign = HorizontalAlign.Center;
FpSpreadGV.Sheets[0].Cells[0, 0, dt.Rows.Count - 1, 21].VerticalAlign = VerticalAlign.Middle;
FpSpreadGV.Sheets[0].PageSize = pageSize;
//锁列 横向滚动时列固定不动
FpSpreadGV.Sheets[0].FrozenColumnCount = 8;
FpSpreadGV.Pager.Mode = FarPoint.Web.Spread.PagerMode.Both;
FpSpreadGV.Pager.Position = FarPoint.Web.Spread.PagerPosition.Bottom;
for (int i = 0; i < FpSpreadGV.Rows.Count; i++)
{
if (FpSpreadGV.ActiveSheetView.Cells[i, 23].Text.Trim() == "1")
{
FpSpreadGV.ActiveSheetView.Rows.Locked = true;
FpSpreadGV.ActiveSheetView.Rows.BackColor = Color.LightGray;
}
else
{
FpSpreadGV.ActiveSheetView.Rows.BackColor = Color.White;
FpSpreadGV.ActiveSheetView.Columns[8, 10].Locked = false;
FpSpreadGV.ActiveSheetView.Columns[12,21].Locked = false;
}
}
} |