62,046
社区成员
发帖
与我相关
我的任务
分享
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="newsID,Us_ID"
DataSourceID="jianweinews" ShowHeader="False" Width="189px" GridLines="None" EmptyDataText="还没有数据" >
<Columns>
<asp:TemplateField ItemStyle-CssClass="hawk110" >
<ItemTemplate >
<asp:HyperLink ID=hyperlink runat="server" NavigateUrl=<%# "~/index/infopublishnews.aspx?newsID="+Eval("newsID")%>>传送</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<SelectedRowStyle BorderStyle="None" />
</asp:GridView>
<asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False"
onrowdatabound="GridView3_RowDataBound" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server"><%#Eval("Name") %></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void GridView3_RowDataBound(object sender, GridViewRowEventArgs e)
{
string[] url = { "1.aspx", "2.aspx", "3.aspx" };
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink hl = e.Row.FindControl("HyperLink1") as HyperLink;
hl.NavigateUrl = url[e.Row.RowIndex];//这里超链接只是例子,具体设置为什么在自己修改
}
}
<script type="text/javascript" language="javascript">
function info(id) {
var url = "OrganizationView.aspx?orgID=" + id;
window.showModalDialog(url, '', 'dialogHeight: 400px;dialogWidth:750px;Top:50px;edge: Raised;center: Yes;help: Yes;');
}
function Update(id) {
var url = "OrganizationUpdate.aspx?orgID=" + id;
window.showModalDialog(url, '', 'dialogHeight: 400px;dialogWidth: 750px;Top:50px;edge: Raised;center: Yes;help: Yes;');
}
function Add() {
var url = "OrganizationAdd.aspx";
window.showModalDialog(url, '', 'dialogHeight: 400px;dialogWidth: 790px;Top:50px;edge: Raised;center: Yes;help: Yes;');
}
function AddAdmin() {
var url = "OrganizationAdminAdd.aspx"
window.showModalDialog(url, '', 'dialogHeight: 400px;dialogWidth: 790px;Top:50px;edge: Raised;center: Yes;help: Yes;');
}
function Save() {
}
</script>
<asp:GridView ID="gridStandard" runat="server" AutoGenerateColumns="False" Width="100%" BorderWidth="1"
OnRowDataBound="gridStandard_RowDataBound" AllowPaging="True"
CellPadding="0" CellSpacing="0" CssClass="mainTable"
AllowSorting="True" onpageindexchanging="gridStandard_PageIndexChanging"
onrowcommand="gridStandard_RowCommand" EmptyDataText="没有符合查询条件的相关数据" >
<Columns>
<asp:TemplateField HeaderText="序号" HeaderStyle-HorizontalAlign="center">
<HeaderStyle BackColor="#CFEAEB" Font-Bold="True" />
<ItemTemplate>
<%# Container.DataItemIndex+1 %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="单位名" HeaderStyle-HorizontalAlign="center">
<HeaderStyle BackColor="#CFEAEB" Font-Bold="True" />
<ItemStyle HorizontalAlign="Left" />
<ItemTemplate>
<%#AspNetHelp.TextHelp.StrSub(Eval("Name"), 30)%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="地址" HeaderStyle-HorizontalAlign="center">
<HeaderStyle BackColor="#CFEAEB" Font-Bold="True" />
<ItemStyle HorizontalAlign="Left" />
<ItemTemplate>
<%#AspNetHelp.TextHelp.StrSub(Eval("Address"), 40)%>
</ItemTemplate>
</asp:TemplateField>
<%-- <asp:BoundField DataField="Name" HeaderText="单位名">
<HeaderStyle BackColor="#CFEAEB" Font-Bold="True" HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="Address" HeaderText="地址">
<HeaderStyle BackColor="#CFEAEB" Font-Bold="True" HorizontalAlign="Left" />
</asp:BoundField>--%>
<asp:TemplateField HeaderText="操作">
<ItemTemplate>
<input id="btninfo" type="button" value="详细" class="grayBtn" onclick='info(<%#Eval("id")%>)' />
<asp:Button ID="btnUpdate" runat="server" Text="编辑" OnClientClick='<%#"Update(" + Eval("id") + ")"%>' CssClass="grayBtn" />
<asp:Button ID="btnDelete" runat="server" Text="删除" CommandArgument='<%#Eval("id")%>' CssClass="grayBtn"
CommandName="Deletes" OnClientClick="if (confirm('删除后无法恢复,您确认删除么?') == false) return false;" />
</ItemTemplate>
<HeaderStyle BackColor="#CFEAEB" Font-Bold="True"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:HyperLink NavigateUrl='<%#"~/test.aspx?ID="+Eval("ID") %>' ID="lnk_test" runat="server" />
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType==DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='Silver'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
e.Row.Attributes.Add("onclick", "selecteRow(this)");
if (tring!=null)
{
e.Row.Attributes.Add("ondblclick", "selectedRow(this)");
}
}
}