[我的ASP.net学习历程]DataGrid(DataBind)(1)

类别:Asp 点击:0 评论:0 推荐:
<%@ Page Language="C#" AutoEventWireup="True" Debug="true" %>
<Script language="C#" runat="server">
void Page_Load(Object Sender,EventArgs e){
 Hashtable HT=new Hashtable();
 HT.Add("1234","Microsoft");
 HT.Add("5678","IBM");
 HT.Add("7895","SUN");
 HT.Add("0123","Orlce");
 
 MyDataGrid.DataSource=HT;
 MyDataGrid.DataBind();
}
</Script>
<form runat="server">
<asp:datagrid ID="MyDataGrid" runat="server" AutoGenerateColumns="false">
<columns>
 <asp:boundcolumn HeaderText="Book Code" DataField="Key"/>
 <asp:boundcolumn HeaderText="Book Title" DataField="Value"/>
 <asp:templatecolumn HeaderText="Information">
  <itemtemplate>
   <asp:checkbox ID="CheckBox" runat="server"/>
  </itemtemplate>
 </asp:templatecolumn>
</columns>
</asp:datagrid>
</form>

本文地址:http://com.8s8s.com/it/it8585.htm