horizontalalign(horizontalalign属性)

horizontalalign(horizontalalign属性)

大家好,关于horizontalalign很多朋友都还不太明白,今天小编就来为大家分享关于horizontalalign属性的知识,希望对各位有所帮助!

javascript怎么触发滚动条事件你是不是想固定表头啊

<style>

.DataGridFixedHeader

{

position:absolute;

overflow:hidden;

top:expression(document.getElementById('dv1').scrollTop-2);

left:6px;

}

</style>

/////

//

////

<asp:GridViewID="gvPl"runat="server"CellPadding="4"ForeColor="#333333"GridLines="Horizontal"

AutoGenerateColumns="False"Width="1500px"

AllowSorting="True"OnRowCommand="gvPl_RowCommand"OnRowDataBound="gvPl_RowDataBound"OnSorting="gvPl_Sorting">

<FooterStyleBackColor="#5D7B9D"Font-Bold="True"ForeColor="White"/>

<RowStyleBackColor="#F7F6F3"ForeColor="#333333"/>

<SelectedRowStyleBackColor="Lavender"Font-Bold="False"ForeColor="#333333"/>

<PagerStyleBackColor="#284775"ForeColor="White"HorizontalAlign="Center"/>

<HeaderStyleBackColor="#5D7B9D"Font-Bold="True"ForeColor="White"Font-Names="宋体"

Font-Size="9pt"CssClass="DataGridFixedHeader"/>

<AlternatingRowStyleBackColor="White"ForeColor="#284775"/>

<Columns>

<asp:TemplateFieldShowHeader="False"Visible="False">

<ItemTemplate>

<asp:ImageButtonID="ImageButton1"runat="server"CausesValidation="false"CommandName="Ed"

ImageUrl="~/images/smalledit.gif"Text="修改"/>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateFieldShowHeader="False"Visible="False">

<ItemTemplate>

<asp:LinkButtonID="LinkButton2"runat="server"CausesValidation="false"CommandName="Dele"

Text="删除"OnClientClick="returnconfirm('您确认删除该记录吗?');"></asp:LinkButton>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateFieldHeaderText="序号">

<ItemStyleHorizontalAlign="Center"Wrap="False"/>

<HeaderStyleWrap="False"/>

<ItemTemplate>

<asp:LabelID="Label1"runat="server"Text='<%#++iRowCount%>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:BoundFieldHeaderText="项目包"DataField="SortName"SortExpression="SortName">

<HeaderStyleWrap="False"HorizontalAlign="Center"/>

<ItemStyleWrap="False"/>

</asp:BoundField>

<asp:BoundFieldDataField="ItemCode"HeaderText="项目编号"SortExpression="ItemCode">

<ItemStyleWrap="False"/>

<HeaderStyleWrap="False"/>

</asp:BoundField>

<asp:BoundFieldHeaderText="项目名称"DataField="ItemName"SortExpression="ItemName">

<HeaderStyleWrap="False"/>

<ItemStyleWrap="False"/>

</asp:BoundField>

<asp:BoundFieldDataField="ItemChkCode"HeaderText="项目批复文号"SortExpression="ItemChkCode">

<ItemStyleWrap="False"/>

<HeaderStyleWrap="False"/>

</asp:BoundField>

<asp:BoundFieldHeaderText="资产属性"DataField="AssetPName"SortExpression="AssetPName">

<HeaderStyleWrap="False"/>

<ItemStyleWrap="False"HorizontalAlign="Center"/>

</asp:BoundField>

<asp:BoundFieldHeaderText="项目性质"DataField="BudgetPName"SortExpression="BudgetPName">

<HeaderStyleWrap="False"/>

<ItemStyleWrap="False"HorizontalAlign="Center"/>

</asp:BoundField>

<asp:BoundFieldHeaderText="建设单位"DataField="BuildName"SortExpression="BuildName">

<HeaderStyleWrap="False"/>

<ItemStyleWrap="False"/>

</asp:BoundField>

<asp:BoundFieldHeaderText="物资名称"DataField="MERCHNAME"SortExpression="MERCHNAME">

<HeaderStyleWrap="False"/>

<ItemStyleWrap="False"/>

</asp:BoundField>

<asp:BoundFieldHeaderText="型号规格"DataField="MODEL"SortExpression="MODEL">

<HeaderStyleWrap="False"/>

<ItemStyleWrap="False"/>

</asp:BoundField>

<asp:BoundFieldHeaderText="计量单位"DataField="MEASURENAME">

<HeaderStyleWrap="False"/>

<ItemStyleHorizontalAlign="Center"Wrap="False"/>

</asp:BoundField>

<asp:BoundFieldHeaderText="数量"DataField="Num"DataFormatString="{0:N6}"HtmlEncode="False"

SortExpression="Num">

<HeaderStyleWrap="False"/>

<ItemStyleHorizontalAlign="Right"Wrap="False"/>

</asp:BoundField>

<asp:BoundFieldHeaderText="单价"DataField="SinglePrice"DataFormatString="{0:N6}"

HtmlEncode="False"SortExpression="SinglePrice">

<HeaderStyleWrap="False"/>

<ItemStyleHorizontalAlign="Right"Wrap="False"/>

</asp:BoundField>

<asp:BoundFieldHeaderText="金额"DataField="TotlePrice"DataFormatString="{0:N}"

HtmlEncode="False"SortExpression="TotlePrice">

<HeaderStyleWrap="False"/>

<ItemStyleHorizontalAlign="Right"Wrap="False"/>

</asp:BoundField>

<asp:BoundFieldHeaderText="交货时间"DataField="PutinMaterialTime"DataFormatString="{0:yyyy-MM-dd}"

HtmlEncode="False"SortExpression="PutinMaterialTime">

<HeaderStyleWrap="False"/>

<ItemStyleHorizontalAlign="Center"Wrap="False"/>

</asp:BoundField>

<asp:BoundFieldDataField="PutinMaterialDD"HeaderText="交货地点"SortExpression="PutinMaterialDD">

<ItemStyleHorizontalAlign="Left"Wrap="False"/>

<HeaderStyleWrap="False"/>

</asp:BoundField>

<asp:BoundFieldDataField="TenderCompanyName"HeaderText="中标单位"SortExpression="TenderCompanyName">

<ItemStyleHorizontalAlign="Left"Wrap="False"/>

<HeaderStyleWrap="False"/>

</asp:BoundField>

<asp:BoundFieldDataField="Remark"HeaderText="备注">

<ItemStyleHorizontalAlign="Left"Wrap="False"/>

<HeaderStyleWrap="False"/>

</asp:BoundField>

<asp:TemplateFieldShowHeader="False"Visible="False">

<ItemTemplate>

<asp:LinkButtonID="LinkButton1"runat="server"CausesValidation="False"CommandName="Select"

Text="选择"></asp:LinkButton>

</ItemTemplate>

</asp:TemplateField>

</Columns>

<EmptyDataTemplate>

<asp:TableID="Table1"runat="server"BackColor="#5D7B9D"Font-Bold="True"ForeColor="White"

Height="22px"Width="1500">

<asp:TableRowID="TableRow1"runat="server">

<asp:TableCellID="TableCell10"runat="server">序号</asp:TableCell>

<asp:TableCellID="TableCell8"runat="server">项目包</asp:TableCell>

<asp:TableCellID="TableCell1"runat="server">项目编号</asp:TableCell>

<asp:TableCellID="TableCell2"runat="server">项目名称</asp:TableCell>

<asp:TableCellID="TableCell3"runat="server">项目批复文号</asp:TableCell>

<asp:TableCellID="TableCell4"runat="server">资产属性</asp:TableCell>

<asp:TableCellID="TableCell9"runat="server">项目性质</asp:TableCell>

<asp:TableCellID="TableCell11"runat="server">建设单位</asp:TableCell>

<asp:TableCellID="TableCell26"runat="server">原合同号</asp:TableCell>

<asp:TableCellID="TableCell19"runat="server">物资名称</asp:TableCell>

<asp:TableCellID="TableCell20"runat="server">型号规格</asp:TableCell>

<asp:TableCellID="TableCell6"runat="server">计量单位</asp:TableCell>

<asp:TableCellID="TableCell7"runat="server">数量</asp:TableCell>

<asp:TableCellID="TableCell12"runat="server">采购单价</asp:TableCell>

<asp:TableCellID="TableCell13"runat="server">采购金额</asp:TableCell>

<asp:TableCellID="TableCell16"runat="server">交货时间</asp:TableCell>

<asp:TableCellID="TableCell22"runat="server">交货地点</asp:TableCell>

<asp:TableCellID="TableCell17"runat="server">中标单位</asp:TableCell>

<asp:TableCellID="TableCell25"runat="server">备注</asp:TableCell>

</asp:TableRow>

</asp:Table>

</EmptyDataTemplate>

<EmptyDataRowStyleCssClass="GvEmptyDataStyle"/>

<EditRowStyleBackColor="#E2DED6"/>

</asp:GridView>

gridview在鼠标点击行时,怎么获取某列的值

我用的是asp.net,GridView实现它的RowDataBound事件,具体看代码,希望可以帮到你:

前台:

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title></title>

<!--点击GridView任意行的位置,获取该行的ID值-->

<scripttype="text/javascript">

functiongetId(row_index){

vargrid_view=document.getElementById('<%=GridView1.ClientID%>');

varrows=grid_view.rows;

varpersonID=rows[row_index].cells[0].innerHTML;

alert("获取的ID为:"+personID);

}

</script>

</head>

<body>

<formid="form1"runat="server">

<div>

<asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="False"OnRowDataBound="GridView1_RowDataBound">

<Columns>

<asp:BoundFieldHeaderText="ID"DataField="ID"HeaderStyle-Width="300px"ItemStyle-HorizontalAlign="Center"

HeaderStyle-BackColor="LightSkyBlue"/>

<asp:BoundFieldHeaderText="Name"DataField="Name"HeaderStyle-Width="300px"ItemStyle-HorizontalAlign="Center"

HeaderStyle-BackColor="LightSkyBlue"/>

<asp:BoundFieldHeaderText="Tel"DataField="Tel"HeaderStyle-Width="300px"ItemStyle-HorizontalAlign="Center"

HeaderStyle-BackColor="LightSkyBlue"/>

</Columns>

</asp:GridView>

</div>

</form>

</body>

</html>

后台代码:

publicpartialclassWebForm1:System.Web.UI.Page

{

protectedvoidPage_Load(objectsender,EventArgse)

{

List<Person>list=newList<Person>();

list.Add(newPerson("001","张三"));

list.Add(newPerson("002","李四"));

list.Add(newPerson("003","王五"));

list.Add(newPerson("004","赵六"));

list.Add(newPerson("005","何七"));

GridView1.DataSource=list;

GridView1.DataBind();

}

protectedvoidGridView1_RowDataBound(objectsender,GridViewRowEventArgse)

{

if(e.Row.RowType==DataControlRowType.DataRow)

{

introw_index=e.Row.RowIndex+1;

e.Row.Attributes.Add("onclick","getId("+row_index+");");

}

}

}

classPerson

{

publicPerson(stringid,stringname)

{

ID=id;

Name=name;

}

privatestringid;

publicstringID

{

get{returnid;}

set{id=value;}

}

privatestringname;

publicstringName

{

get{returnname;}

set{name=value;}

}

privatestringtel;

publicstringTel

{

get{returntel;}

set{tel=value;}

}

}

如何为ASPxGridView添加序号列

说起,相信很多学习.net的朋友并不会陌生。本文将由达内的讲师详细为您介绍关于的相关常识。AspxGridView与GridView控件一样,都是操作大数据量的列表数据的控件。那么我们如何像GridView控件一样,为AspxGridView控件添加一个序号列呢?就像下图一样:有了序号列,用户可以快速定位自己想要的数据,对用户的体验度可加分不少哦。一,首先为AspxGridView添加序号列///<summary>

///为AspxGridView添加序号列,附件数量列

///</summary>

///<paramname="_grid"></param>

publicvoidSetGridAddNumberCol(AspxGridView_grid){if(_grid!=null){if(_grid.Columns["序号"]==null){GridViewDataTextColumncol=newGridViewDataTextColumn();

col.HeaderStyle.HorizontalAlign=HorizontalAlign.Center;

col.CellStyle.HorizontalAlign=HorizontalAlign.Center;

col.EditFormSettings.Visible=DevExpress.Web.ASPxClasses.DefaultBoolean.False;

col.Caption="序号";

col.VisibleIndex=0;

_grid.Columns.Add(col);//这里主要是用来设置序号列的显示顺序,我们总是希望序号列显示在列表的最前面吧,但如果前面还有一个选择列的话,序号列就应该位于选择列的后面,也就是第二列。当然了,这段代码是可以根据情况来修改或者可以完全删除掉的。

boolisvisible;

if(_grid.Columns[0].GetType().Name!="GridViewCommandColumn"){for(inti=0;i<_grid.Columns.Count;i++){if(_grid.Columns[i].Caption=="序号")

_grid.Columns[i].VisibleIndex=0;else{isvisible=_grid.Columns[i].Visible;

_grid.Columns[i].VisibleIndex=_grid.Columns[i].VisibleIndex+1;

_grid.Columns[i].Visible=isvisible;}}}}}二,添加后序后,还需要为该列赋值,当然了,这个就相当的简单了,我们只需要在AspxGridView的Grid_HtmlDataCellPrepared事件中为"序号"这个栏位赋值就好了,代码如下:protectedvoidGrid_HtmlDataCellPrepared(objectsender,AspxGridViewTableDataCellEventArgse){if(IsCreateNumberCol&&e.DataColumn.Caption=="序号"){

e.Cell.Text=(e.VisibleIndex+1).ToString();}}如果你的数据源有使用了分页存储过程,而又想使用翻页后的序号是连续的,你可以改写填充序号的代码如下:protectedvoidGrid_HtmlDataCellPrepared(objectsender,AspxGridViewTableDataCellEventArgse){if(IsCreateNumberCol&&e.DataColumn.Caption=="序号"){

e.Cell.Text=(e.VisibleIndex+(AspxGridViewID.PageIndex*AspxGridViewID.SettingsPager.PageSize)+1).ToString();}}注意:使用这个方法添加上的序号值,在使用DevExpress导出控件导出数据的时候是导不出来的。如果要想导出序号值,只有数据源中包含序号值才行。现在,相信朋友们对于了解的更加清楚了,达内培训作为IT培训的领导品牌,为互联网行业培养了无数精英。

horizontalalign的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于horizontalalign属性、horizontalalign的信息别忘了在本站进行查找哦。

发表评论
留言与评论(共有 0 条评论)
   
验证码:

相关文章