Note that there are some explanatory texts on larger screens.

plurals
  1. POList of file's extension can be edited text in an editor
    text
    copied!<p>Try to explain so clearly, hope you can understand my problem.</p> <p>My aspx page allows client uploading file (allows all extension of file) into a root folder. Then in that aspx page, it has an Repeater control to display all files uploaded. </p> <p><img src="https://i.stack.imgur.com/N7z32.png" alt="enter image description here"></p> <p>I'm stuck in finding the way to detect which file can be edited in an editor control. </p> <p>For example: <code>if item= xml file --&gt; show Edit Text</code></p> <pre><code>if item= source code file ---&gt; show Edit Text </code></pre> <p>In <code>Repeater1_ItemDataBound</code> function, in the last <code>else if</code> statement, it is added the <code>Edit Text</code> function whenever the item is: textfile, source code, xml file... more more...</p> <p>In my code below, I can do it which some file's extension, but I know it not enough. </p> <p>Help!!!</p> <p>If you dont really understand, please ask!!!</p> <pre><code>&lt;asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand" OnItemDataBound="Repeater1_ItemDataBound"&gt; &lt;ItemTemplate&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:Label ID="imagelabel" runat="server" Text=""&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:LinkButton ID="lnkFolder" runat="server" Text='&lt;%# Eval("Name") %&gt;' CommandName="Select"&gt;&lt;/asp:LinkButton&gt; &lt;/td&gt; &lt;td &gt; &lt;asp:LinkButton ID="LinkButton1" runat="server" Text="&lt;img src='pic/trash.png'/&gt; Delete" CommandArgument='&lt;%# Eval("Path") +"," + Eval("Type")%&gt;'CommandName="Delete"&gt; &lt;/asp:LinkButton&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:LinkButton ID="LinkButton2" runat="server" Text="&lt;img src='pic/gear--pencil.png'/&gt; Rename" CommandArgument='&lt;%# Eval("Path") + "," + Eval("Type") + "," + Eval("Name")%&gt;'CommandName="Edit"&gt;&lt;/asp:LinkButton&gt; &lt;/td&gt; &lt;td&gt; asp:LinkButton ID="lbtnEditText" runat="server" Text="" CommandArgument='&lt;%# Eval("Path") + "," + Eval("Name")%&gt;'CommandName="EditText" OnCommand="Button1_Click"&gt;&lt;/asp:LinkButton&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; </code></pre> <p>Take a look at my <code>Repeater1_ItemDataBound</code> function:</p> <pre><code> protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (((DataRowView)e.Item.DataItem).Row["Type"].ToString() == "D")// if item= folder { ((Label)e.Item.FindControl("imagelabel")).Text = "&lt;img src='pic/folder.png'&gt;"; } else { string fileExtension = ((DataRowView)e.Item.DataItem).Row["Extension"].ToString(); if (fileExtension.Equals(".gif") || fileExtension.Equals(".jpg") || fileExtension.Equals(".png")) ((Label)e.Item.FindControl("imagelabel")).Text = "&lt;img src='pic/gallery.jpg'&gt;"; else if (fileExtension.Equals(".doc") || fileExtension.Equals(".docx")) ((Label)e.Item.FindControl("imagelabel")).Text = "&lt;img src='pic/doc.gif'&gt;"; else if (fileExtension.Equals(".pdf")) ((Label)e.Item.FindControl("imagelabel")).Text = "&lt;img src='pic/pdf.gif'&gt;"; else if (fileExtension.Equals(".xls")) ((Label)e.Item.FindControl("imagelabel")).Text = "&lt;img src='pic/excel.gif'&gt;"; else if??? { ((Label)e.Item.FindControl("imagelabel")).Text = "&lt;img src='pic/Text.gif'&gt;"; //add Edit Text function here ((LinkButton)e.Item.FindControl("lbtnEditText")).Text = "&lt;img src='pic/pe.png'/&gt; Edit Text"; } } } </code></pre>
 

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