asp.net - Hide or Delete a whole GridView row with specific text in the field -


this first post here.

i have simple asp.net query-string driven page gridview lists contents of specific folders (based on query-string).some of these folders contain pdf's, means on windows file-server creates thumbs.db file (contains thumbnail images folder views), unfortunately file listed in gridview , looks unsightly, there way can alter code of gridview delete or hide rows contain thumbs.db in name column.

code behind (vb.net)(shortened there lot of folders):

protected sub page_load(byval sender object, byval e system.eventargs) handles     me.load      dim certs new io.directoryinfo("d:\procedures\certs\")  dim q string     q = request.querystring("type")  if q = "certs"         lbltype.text = "certs"         gridview1.datasource = certs.getfiles()         gridview1.databind() end if end sub 

aspx code:

asp:gridview id="gridview1" runat="server" autogeneratecolumns="false" cellpadding="4"     cssclass="gridstyle" forecolor="#333333" gridlines="none" width="100%">     <columns>         <asp:templatefield headertext="document name" sortexpression="name">             <itemtemplate>                 <asp:hyperlink id="hyperlink1" navigateurl='<%#"http://intranet.(hidden).com/sqe/data/" + request.querystring("type") + "/" + eval("name")%>' target="_blank" runat="server"><%#eval("name")%></asp:hyperlink>             </itemtemplate>         </asp:templatefield>         <asp:boundfield datafield="extension" headertext="extension" sortexpression="name" />         <asp:boundfield datafield="length" headertext="file size" sortexpression="name" />         <asp:boundfield datafield="lastaccesstime" headertext="last modified" sortexpression="name" />     </columns> 

many in advance help.

you can in gridview_rowbound event

protected void gridview1_rowdatabound(object sender, gridviewroweventargs e) {     if (e.row.rowtype == datacontrolrowtype.datarow)     {      hyperlink hl = (hyperlink) e.row.findcontrol("hyperlink1");        if (hl.text == "thumb.db")        {        e.row.visible=false;        }     } } 

porting vb easy you?


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -