Hi chandru
I just modifed your code in Gridview in aspx file
and used gridview rowdatabound event to check uploaded video url existed or not .By verifying i am showing or hiding download link ,
and Imported two namespaces
aspx
-------------------------------------------------------------------------------------------------------------------------------------------------------
<asp:GridView ID="GridVideofile" runat="server" AutoGenerateColumns="false" Width="647px"
CssClass="GV" onrowdatabound="GridVideofile_RowDataBound"
ShowHeader="False">
<FooterStyle CssClass="Gv-Footer" />
<HeaderStyle CssClass="Gv-HRow" />
<PagerStyle CssClass="Gv-Pager" />
<RowStyle CssClass="Gv-Row" />
<SelectedRowStyle CssClass="Gv-SRow" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table>
<tr>
<td>
Posted Date :
<%#Eval("Jdate")%>
</td>
</tr>
<tr>
<td>
No of Views :
<%#Eval("ViewCount")%>
</td>
</tr>
<tr id="trVideoFile" runat="server" style="display:none">
<td>
Download Video File :
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Download File</asp:LinkButton>
</td>
</tr>
<tr>
<td>
Url Video File :
<a href='<%#Eval("Url") %>' target="_blank"><%#Eval("Url")%></a>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
-------------------------------------------------------------------------------------------------------------------------------------------------------
aspx.cs
Import these namespacess
using System.IO;
using System.Web.UI.HtmlControls;
protected void GridVideofile_RowDataBound(object sender,GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string url = DataBinder.Eval(e.Row.DataItem, "Url").ToString();
HtmlTableRow trVideoFile = (HtmlTableRow)e.Row.FindControl("trVideoFile");
if (url.Length > 0)
{
if (File.Exists(url))
{
trVideoFile.Style["display"] = "";
}
else
trVideoFile.Style["display"] = "none";
}
else
trVideoFile.Style["display"] = "none";
}
}
cheers
Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator