Bind ArrayList to asp datagrid (C#) : DataGrid « Data Binding « ASP.Net






Bind ArrayList to asp datagrid (C#)

<%@Page Language="C#"%>
<html>
<body>

<asp:datagrid  id="dgrTest" runat="server"
               forecolor="#000000"
               backcolor="#ffffff"
               cellpadding="3"
               gridlines="none"
               width="50%"
               font-name="tahoma,arial,sans-serif"
               font-size="14px">
  <headerstyle forecolor="#ffffff"
               backcolor="#808080"
               font-name="tahoma,arial,sans-serif"
               font-size="12px"
               font-bold="true"
               wrap="false" />
  <itemstyle   font-name="tahoma,arial,sans-serif"
               font-size="10px" />
  <alternatingitemstyle font-name="tahoma,arial,sans-serif"
               font-size="16px"
               backcolor="#ffff00" />
</asp:datagrid>

</body>
</html>

<script Language="C#" runat="server">

void Page_Load() {

   // create an ArrayList of values to bind to
   ArrayList arrValues = new ArrayList(4);
   arrValues.Add("A");
   arrValues.Add("B");
   arrValues.Add("C");
   arrValues.Add("D");
   arrValues.Add("E");

   // set the DataSource property of the control to the
   // array and bind it to display the values
   dgrTest.DataSource = arrValues;
   dgrTest.DataBind();

}

</script>

           
       








Related examples in the same category

1.Bind data to asp:datagrid (VB.net)
2.Bind hashtable to asp datagrid (C#)