<%@Page language="C#" EnableViewState="False" %> <script runat="server"> void Page_Load(object sender, EventArgs e) { //Create an array (that'll be the DataSource for out DataGrid). //Instead of an array, we could've used a dataset, a dataview, or whatever
<%@Page language="C#" EnableViewState="False" %> <script runat="server"> void Page_Load(object sender, EventArgs e) { //Create an array (that'll be the DataSource for out DataGrid). //Instead of an array, we could've used a dataset, a dataview, or whatever string[] x = new string[13]; for(int i=0;i<13;i++) x = "xx"; /*This stores the length of the array. Alternatively, you can use DataSet.Rows.Length, to get the Number of rows in the dataset */ int len = x.Length; DG1.DataSource = x; DataBind(); } </script> <html> <body> <form runat="server"> <aspatagrid runat="server" EnableViewState="false" id="DG1" > <Columns> <asp:TemplateColumn> <ItemTemplate> <%# l - Container.DataSetIndex %> </ItemTemplate> </asp:TemplateColumn> </Columns> </aspatagrid> </form> </body> </html>
השינויים הודגשו.
פה אנחנו נאלצים לחרוג קצת מה-DataGrid, ולעבור קצת אל ה-DataSet (או אל המערך, או אל כל DataSource אחר), כדי לקבל את המספר הכולל של הרשומות.