日期:2014-05-17 浏览次数:20423 次
<asp:GridView runat="server" ID="gv" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="EmployeeID" HeaderText="ID" />
<asp:TemplateField HeaderText="个人信息">
<ItemTemplate>
<p>名:<%# Eval("FirstName") %></p>
<p>姓:<%# Eval("LastName") %></p>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:GridView runat="server" ID="gv" AutoGenerateColumns="false"
OnRowCommand="OnSelected" DataKeyNames="EmployeeID">
<Columns>
<asp:ButtonField ButtonType="Button" CommandName="select" Text="select" />
<asp:BoundField DataField="EmployeeID" />
<asp:BoundField DataField="LastName" />
</Columns>
</asp:GridView>
<br />
<asp:DetailsView runat="server" ID="dv">
</asp:DetailsView>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string strConn = WebConfigurationManager.ConnectionStrings["Northwind"].ToString();
SqlConnection conn = new SqlConnection(strConn);
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandText = "select * from Employees";
&nb