在GridView里面嵌入Button
<Columns>
<asp:TemplateField HeaderText="选择">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:Button ID="CheckButton" runat="server" Text="查看" CommandArgument= <%# Eval("Code") %>
OnCommand="CheckButton_Click"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Code" HeaderText="学号">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
</Columns>
protected void CheckButton_Click(object sender, CommandEventArgs e)
{
string studentcode = e.CommandArgument.ToString();
}
<asp:TemplateField HeaderText="选择">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:Button ID="CheckButton" runat="server" Text="查看" CommandArgument= <%# Eval("Code") %>
OnCommand="CheckButton_Click"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Code" HeaderText="学号">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
</Columns>
protected void CheckButton_Click(object sender, CommandEventArgs e)
{
string studentcode = e.CommandArgument.ToString();
}