how create visible and invisible for linkbutton in gridview?

Posted by Chandru_ra under Regular Expressions on 7/16/2011 | Points: 10 | Views : 4614 | Status : [Member] | Replies : 4
Dear all,

now am using gridview linkbutton using downlod link no file upload invisible for linkbutton or upload for any file visible in linkbutton how
<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>



<tr>
<td>
Posted Date :
<%#Eval("Jdate")%>
</td>
</tr>
<tr>
<td>
No of Views :
<%#Eval("ViewCount")%>
</td>
</tr>
<tr>
<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>

</Columns>
</asp:GridView>

Advance Thanks to all

chandru


Responses

Posted by: DotnetGuy on: 7/16/2011 [Member] Starter | Points: 25

Up
0
Down
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

Posted by: Chandru_ra on: 7/16/2011 [Member] Starter | Points: 25

Up
0
Down
hi,
ur coding is correct but am using linkbutton and href alternate puposing uploads..

some uplosd for any files and some times url upload, but only one uploaded files.

this is result for always display none for linkbutton..

i want alternate display for linkbutton and url ..

chandru

Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: DotnetGuy on: 7/16/2011 [Member] Starter | Points: 25

Up
0
Down
Hi chandru,

Are you saving uploaded path into database ,if it is saving then check that Uploaded Path in place of Url so that it will work fine. and if linkbutton and href alternate, give id to the video url and find the control in rowdatabound make it show or hide

cheers

Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chandru_ra on: 7/18/2011 [Member] Starter | Points: 25

Up
0
Down
hi,

am saving in upload files in database, so how it use this concept..

chandru

Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response