Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to put newer files at top of datagrid?
    primarykey
    data
    text
    <p>Here is a script for displaying name of files (for download) in data grid table. Is it possible that to show the latest created file in top row?. Please help. </p> <pre><code>&lt;%@ Import Namespace="System.IO" %&gt; &lt;script language="VB" runat="server"&gt; Sub Page_Load(sender as Object, e as EventArgs) If Not Page.IsPostBack then Dim dirInfo As New DirectoryInfo("D:\SeverUpload\Safety") articleList.DataSource = dirInfo.GetFiles("*.*") articleList.DataBind() End If End Sub Sub articleList_ItemDataBound(sender as Object, e as DataGridItemEventArgs) ' First, make sure we're NOT dealing with a Header or Footer row If e.Item.ItemType &lt;&gt; ListItemType.Header AND _ e.Item.ItemType &lt;&gt; ListItemType.Footer then 'Now, reference the Button control that the Delete ButtonColumn 'has been rendered to Dim deleteButton as Button = e.Item.Cells(0).Controls(0) 'We can now add the onclick event handler deleteButton.Attributes("onclick") = "javascript:return " &amp; _ "confirm('Are you sure you want to delete the file " &amp; _ DataBinder.Eval(e.Item.DataItem, "Name") &amp; "?')" End If End Sub Sub articleList_DeleteFile(sender as Object, e as DataGridCommandEventArgs) 'First, get the filename to delete Dim fileName as String = articleList.DataKeys(e.Item.ItemIndex) 'lblMessage.Text = "You opted to delete the file " &amp; _ 'fileName &amp; ".&lt;br /&gt;" &amp; _ '"This file could be deleted by calling: " &amp; _ '"&lt;code&gt;File.Delete(FileName)&lt;/code&gt;&lt;p&gt;" 'You would want to rebind the Directory's files to the DataGrid after 'deleting the file... End Sub &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload