Hi comunidadmexi...,
Use Button control insted of LinkButton and set css to style Button look as LinkButton.
Refer below sample.
HTML
<asp:ScriptManager runat="server" />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Name" />
<asp:TemplateField HeaderText="" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:HiddenField ID="hfCountry" runat="server" Value='<%# Eval("Country") %>' />
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<div class="modal">
<div class="center">
<img alt="" src="progress.gif" />
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Link" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Button ID="Link" runat="server" Text="Download" OnClick="OnDownload" CssClass="buttonLink" />
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<style type="text/css">
body {
margin: 0;
padding: 0;
font-family: Arial;
}
.modal {
position: fixed;
left: 0;
z-index: 999;
height: 100%;
width: 100%;
top: 0;
background-color: Black;
filter: alpha(opacity=60);
opacity: 0.6;
-moz-opacity: 0.8;
}
.center {
z-index: 1000;
margin: 30px auto;
padding: 10px;
width: 130px;
background-color: White;
border-radius: 10px;
filter: alpha(opacity=100);
opacity: 1;
-moz-opacity: 1;
}
.center img {
height: 128px;
width: 128px;
}
.buttonLink {
background: none !important;
border: none;
padding: 0 !important;
font-family: arial, sans-serif;
color: #069;
text-decoration: underline;
cursor: pointer;
}
</style>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.AddRange(new System.Data.DataColumn[3]
{
new System.Data.DataColumn("Id"),
new System.Data.DataColumn("Name"),
new System.Data.DataColumn("Country")
});
dt.Rows.Add(1, "John Hammond", "United States");
dt.Rows.Add(2, "Mudassar Khan", "India");
dt.Rows.Add(3, "Suzanne Mathews", "France");
dt.Rows.Add(4, "Robert Schidner", "Russia");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void OnDownload(object sender, EventArgs e)
{
Button btn = (Button)sender;
GridViewRow row = btn.NamingContainer as GridViewRow;
string ese = (row.FindControl("hfCountry") as HiddenField).Value;
if (!string.IsNullOrEmpty(ddl.SelectedValue))
{
Response.Redirect("xls.aspx?e=" + ese.ToString() + "&a=" + ddl.SelectedValue);
}
else
{
Response.Redirect("xls.aspx?e=" + ese.ToString());
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim dt As System.Data.DataTable = New System.Data.DataTable()
dt.Columns.AddRange(New System.Data.DataColumn(2) {
New System.Data.DataColumn("Id"),
New System.Data.DataColumn("Name"),
New System.Data.DataColumn("Country")})
dt.Rows.Add(1, "John Hammond", "United States")
dt.Rows.Add(2, "Mudassar Khan", "India")
dt.Rows.Add(3, "Suzanne Mathews", "France")
dt.Rows.Add(4, "Robert Schidner", "Russia")
GridView1.DataSource = dt
GridView1.DataBind()
End If
End Sub
Protected Sub OnDownload(ByVal sender As Object, ByVal e As EventArgs)
Dim btn As Button = CType(sender, Button)
Dim row As GridViewRow = TryCast(btn.NamingContainer, GridViewRow)
Dim ese As String = (TryCast(row.FindControl("hfCountry"), HiddenField)).Value
If Not String.IsNullOrEmpty(ddl.SelectedValue) Then
Response.Redirect("xls.aspx?e=" & ese.ToString() & "&a=" & ddl.SelectedValue)
Else
Response.Redirect("xls.aspx?e=" & ese.ToString())
End If
End Sub