一些
//对于没有数字的内容,下面这行完全满足要求,但加了数字就不行,必须调用OnItemDataBound
ItemsGrid.Attributes.Add("style","word-break:keep-all;word-wrap:normal");
//下面这行是自动换行
//ItemsGrid.Attributes.Add("style","word-break:break-all;word-wrap:break-word");
4. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
foreach (TableCell cell in e.Row.Cells)
cell.Attributes.Add("style", "FONT-WEIGHT:normal");
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
int t = this.GridView1.PageIndex * 15 + (e.Row.RowIndex + 1);
e.Row.Cells[0].Text = t.ToString();
e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Center;
e.Row.Cells[1].Attributes.Add("onclick", "location.href='wwwrecorder.aspx?empno=" + e.Row.Cells[1].Text + "&time=" + this.tbto.Value + "'");
e.Row.Cells[1].Attributes.Add("onmouseout", "this.style.backgroundColor=\"" + e.Row.Style["BACKGROUND-COLOR"] + "\"");
e.Row.Cells[1].Attributes.Add("onmouseover", "javescript:this.style.cursor='hand';this.style.backgroundColor=\"" + "#FF8080" + "\"");
}
}
1、,
string str="";
2、html:
Text='<%=str%>'
3.要在Web.Config 裏面加上
<identity impersonate="true" userName="innolux\f3111900" password="luo528515" />
2.
<ItemTemplate>
<%# DataGrid1.CurrentPageIndex * DataGrid1.PageSize + Container.ItemIndex+1%>
</ItemTemplate>
1.雙表頭
要設置 showheader 屬性為true
private int m_CreatePageTimess=0;
private void Datagrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
switch(e.Item.ItemType)
{
case ListItemType.Pager:
{
#region
if(m_CreatePageTimess==0)
{
DataGridItem row=(DataGridItem)e.Item;
row.Cells.Clear();
row.HorizontalAlign=HorizontalAlign.Center;
row.BackColor=System.Drawing.Color.SeaGreen;
row.ForeColor=System.Drawing.Color.White;
TableCell cell0=new TableCell();
cell0.RowSpan=2;
cell0.Width=Unit.Pixel(80);
cell0.Controls.Add(new LiteralControl("Model Name"));
TableCell cell1=new TableCell();
cell1.RowSpan=2;
cell1.Width=Unit.Pixel(80);
cell1.Controls.Add(new LiteralControl("PM"));
TableCell cell2=new TableCell();
cell2.RowSpan=2;
cell2.Width=Unit.Pixel(80);
cell2.Controls.Add(new LiteralControl("試作編號"));
TableCell cell3=new TableCell();
cell3.RowSpan=2;
cell3.Width=Unit.Pixel(130);
cell3.Controls.Add(new LiteralControl("產品開發階段"));
row.Cells.Add(cell0);
row.Cells.Add(cell1);
row.Cells.Add(cell2);
row.Cells.Add(cell3);
NPTR.ICL.Command cm=new Command();
string date=System.DateTime.Now.Date.ToShortDateString();
string week=cm.GetWeekName(date).Substring(1);
int wk=Convert.ToInt32(week);
for(int i=1;i<=4;i++)
{
TableCell cell4=new TableCell();
cell4.ColumnSpan=3;
cell4.Text="W"+wk;
row.Cells.Add(cell4);
wk++;
}
m_CreatePageTimess++;
}
break;
#endregion
}
case ListItemType.Header:
{
#region
DataGridItem head=(DataGridItem)e.Item;
head.Cells.Clear();
head.VerticalAlign=VerticalAlign.Middle;
head.HorizontalAlign=HorizontalAlign.Center;
head.BackColor=System.Drawing.Color.SeaGreen;
head.ForeColor=System.Drawing.Color.White;
for(int k=1;k<=4;k++)
{
TableCell cell01=new TableCell();
cell01.Width=Unit.Pixel(110);
cell01.Text="預計投入日期";
TableCell cell02=new TableCell();
cell02.Width=Unit.Pixel(110);
cell02.Text="預計投入數量";
TableCell cell03=new TableCell();
cell03.Width=Unit.Pixel(110);
cell03.Text="BOM Version";
head.Cells.Add(cell01);
head.Cells.Add(cell02);
head.Cells.Add(cell03);
}
break;
#endregion
}
浙公网安备 33010602011771号