c# - How to insert picture in gridview using path that is stored in text file? -


i have insert pictures paths stored in text file. text file looks this:

aiph7,iphone 7 plus 256gb__,iphone,____,~/pictures/iphone7plus.jpg______,999€______ aszg0,zenfone go_________,asus______,~/pictures/zenphonego.jpg_______,138€______

i want insert picture in gridview file location in text file. gridview auto generated function reads data file , puts gridview:

string filepath = @"c:\users\pc1\desktop\project\webapplication1\file.txt";  public datatable converttodatatable(string filepath, int numberofcolumns)       {         datatable tbl = new datatable();         (int col = 0; col < numberofcolumns; col++)         tbl.columns.add(new datacolumn("column" + (col + 1).tostring()));          string[] lines = file.readalllines(filepath);         list<string> list1 = new list<string>();         foreach (string line in lines)         {             var cols = line.split(',');             datarow dr = tbl.newrow();             (int cindex = 0; cindex < 5; cindex++)             {                 if (cols[cindex].contains('_'))                 {                     cols[cindex] = cols[cindex].substring(0, cols[cindex].indexof('_'));                     dr[cindex] = cols[cindex];                 }                 else                 {                     cols[cindex] += '_';                     cols[cindex] = cols[cindex].substring(0, cols[cindex].indexof('_'));                     dr[cindex] = cols[cindex];                 }             }             (int cindex = 0; cindex < 5; cindex++ )                 if (dr[cindex].tostring() == promenljiva)                     tbl.rows.add(dr);         }          this.gridview1.datasource = tbl;         this.gridview1.databind();          return tbl;     } 

after have:

converttodatatable(filepath, 5);  

this gridview:

<asp:gridview id="gridview1" runat="server"></asp:gridview> 


Comments