问题描述
好了,所以我的目标是到GridView HEADR实例下添加只有1静态行:
| coloumnHeader1 | coloumnHeader2 | coloumnHeader3 | coloumnHeader4 |
| ----------------------静态行---------------------- ----- |
| DataBoundField | DataBoundField | DataBoundField | DataBoundField |
| DataBoundField | DataBoundField | DataBoundField | DataBoundField |
| DataBoundField | DataBoundField | DataBoundField | DataBoundField |
| DataBoundField | DataBoundField | DataBoundField | DataBoundField |
| DataBoundField | DataBoundField | DataBoundField | DataBoundField |
| DataBoundField | DataBoundField | DataBoundField | DataBoundField |
| ----------------------页脚----------------------- -------- |
我的预感是其得到的东西用的RowDataBound但是这是据我已经得到。
我想我需要更好地解释自己:我想要做什么是相当于增加一个新的HeaderRow ...
日Thnx所有助手:D
找到了答案:
很多谷歌上搜索,我发现我一直在寻找后,
在ASP
< ASP:GridView控件在preRender =grd_ pre的CssClass =表ID =GridView1=服务器的AutoGenerateColumns =FALSE
>
在后面
在code 保护无效grd_ pre(对象发件人,EventArgs的发送)
{
GridViewRow GV =新GridViewRow(0,0,DataControlRowType.Header,DataControlRowState.Normal);
TableCell的TC =新的TableCell();
tc.ColumnSpan = 3;
tc.Text =GridView的头;
tc.Attributes.Add(风格,文本对齐:中心);
gv.Cells.Add(TC);
this.GridView1.Controls [0] .Controls.AddAt(0,GV);
}
找到了答案:
很多谷歌上搜索,我发现我一直在寻找后,
在ASP
< ASP:GridView控件在preRender =grd_ pre的CssClass =表ID =GridView1=服务器的AutoGenerateColumns =FALSE
>
在后面
在code 保护无效grd_ pre(对象发件人,EventArgs的发送)
{
GridViewRow GV =新GridViewRow(0,0,DataControlRowType.Header,DataControlRowState.Normal);
TableCell的TC =新的TableCell();
tc.ColumnSpan = 3;
tc.Text =GridView的头;
tc.Attributes.Add(风格,文本对齐:中心);
gv.Cells.Add(TC);
this.GridView1.Controls [0] .Controls.AddAt(0,GV);
}
ok so my goal is to add only 1 static row under the gridview headr EXAMPLE:
|coloumnHeader1|coloumnHeader2|coloumnHeader3|coloumnHeader4|
|----------------------static Row---------------------------||DataBoundField|DataBoundField|DataBoundField|DataBoundField||DataBoundField|DataBoundField|DataBoundField|DataBoundField||DataBoundField|DataBoundField|DataBoundField|DataBoundField||DataBoundField|DataBoundField|DataBoundField|DataBoundField||DataBoundField|DataBoundField|DataBoundField|DataBoundField||DataBoundField|DataBoundField|DataBoundField|DataBoundField|
|----------------------Footer-------------------------------|
my hunch is its got something with RowDataBound but that's as far as i have got.
i guess i need to explain myself better : what i want to do is the equivalent to adding a new HeaderRow...thnx for all the helpers :D
FOUND THE ANSWER:after a lot of googling i found what i was looking for ,on the asp
<asp:GridView OnPreRender="grd_Pre" CssClass="table" ID="GridView1" runat="server" AutoGenerateColumns="False"
>
in the code behind
protected void grd_Pre(object sender, EventArgs e)
{
GridViewRow gv = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);
TableCell tc = new TableCell();
tc.ColumnSpan = 3;
tc.Text = "GridView Header";
tc.Attributes.Add("style", "text-align:center");
gv.Cells.Add(tc);
this.GridView1.Controls[0].Controls.AddAt(0, gv);
}
FOUND THE ANSWER:after a lot of googling i found what i was looking for ,on the asp
<asp:GridView OnPreRender="grd_Pre" CssClass="table" ID="GridView1" runat="server" AutoGenerateColumns="False"
>
in the code behind
protected void grd_Pre(object sender, EventArgs e)
{
GridViewRow gv = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);
TableCell tc = new TableCell();
tc.ColumnSpan = 3;
tc.Text = "GridView Header";
tc.Attributes.Add("style", "text-align:center");
gv.Cells.Add(tc);
this.GridView1.Controls[0].Controls.AddAt(0, gv);
}
这篇关于如何将静态行添加到GridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!