Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am binding details of user in datalist .In datalist i want to bind File Name insted of Full Path of Document which is uploaded by user.In Database i store the Full Path of document in column FolderName. In FolderName column i store the full path of document. I am binding datalist using view.

XML
<asp:DataList runat="server" ID="dlContacts" Width="100%"
                BorderStyle="Groove" >
                <HeaderTemplate>
                    <table width="100%">
                        <tr>
                            <td>
                                OrganisationName
                            </td>
                            <td>
                                Details
                            </td>
                            <td>
                            File Name
                            </td>
                        </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td>
                            <%#Eval("OrganisationName")%>
                        </td>
                        <td>
                            <%#Eval("OrganisationDetails")%>
                        </td>
                        <td>
                         (<%# Eval(System.IO.Path.GetFileName("FolderName")%>)
                        </td>
                        <td style="text-align: right;">
                            <asp:Button ID="btnEdit" Text="Edit" runat="server" CommandName="edit" />
                        </td>
                        <td style="text-align: right;">
                            <asp:Button ID="btnDelete" Text="Delete" runat="server" CommandName="delete" />
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                    </table></FooterTemplate>
            </asp:DataList>
Posted

1 solution

try this... just make an adjustment based on your variables.

string Filename = CompletePath.Substring(CompletePath.LastIndexOf("\\") + 1);


now, if your data is stored in a datatable, either you modify the datatable, add a column, and fill that column with the extracted filename before binding to a list, or handle the binding's rowdatabound event to handle the extraction of filename.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900