62,046
社区成员
发帖
与我相关
我的任务
分享
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="开课编号"
DataSourceID="SqlDataSource1"
Width="738px" OnRowCommand="GridView1_RowCommand" EmptyDataText="数据库中无匹配的纪录">
<Columns>
<asp:BoundField DataField="开课状态" HeaderText="开课状态" SortExpression="开课状态" />
<asp:BoundField DataField="班级编号" HeaderText="班级编号" ReadOnly="True" SortExpression="班级编号" />
<asp:BoundField DataField="班级性质" HeaderText="班级性质" SortExpression="班级性质" />
<asp:BoundField DataField="培训种类" HeaderText="培训种类" ReadOnly="True" SortExpression="培训种类" />
<asp:BoundField DataField="上课时间" HeaderText="上课时间" SortExpression="上课时间" />
<asp:BoundField DataField="地点" HeaderText="地点" SortExpression="地点" />
<asp:BoundField DataField="费用" DataFormatString="{0:C0}" HeaderText="费用" SortExpression="费用" HtmlEncode="False" />
<asp:ButtonField CommandName="网上报名" DataTextField="网上报名" HeaderText="网上报名" Text="按钮" />
<asp:TemplateField HeaderText="网上报名" ShowHeader="False">
<ItemTemplate >
<asp:Button ID="Button1" runat="server" CausesValidation="False" Enabled='<%# Eval("网上报名") %>'
Text='<%# "报名" %>' CommandArgument='<%# Eval("网上报名") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
//取得那行的行索引
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GridView1.Rows[e.CommandArgument].Cells[1].Text + "');</script>");
}