Click here to Skip to main content
15,895,192 members

Comments by Ankit 71 (Top 8 by date)

Ankit 71 9-Oct-14 1:48am View    
after download it shows an error ,, i dont think so that code is wrong
Ankit 71 9-Oct-14 1:43am View    
This is code of CS Page

LinkButton lnkbtn = sender as LinkButton;
GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
int fileId = Convert.ToInt32(gvUploadedFiles.DataKeys[gvrow.RowIndex].Value.ToString());
using (SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString()))
{
using (SqlCommand sqlCmd = new SqlCommand())
{
sqlCmd.CommandText = "SELECT * FROM song WHERE id=@id";
sqlCmd.Parameters.AddWithValue("@id", fileId);
sqlCmd.Connection = sqlConn;
sqlConn.Open();
SqlDataReader dr = sqlCmd.ExecuteReader();
if (dr.Read())
{
string fileName = dr["songname"].ToString();
string fileLength = dr["FileSize"].ToString();
string filePath = dr["FilePath"].ToString();
if (File.Exists(filePath))
{

using (ZipFile zip = new ZipFile())
{
zip.AlternateEncodingUsage = ZipOption.AsNecessary;
zip.AddDirectoryByName("Top Songs");
foreach (GridViewRow row in gvUploadedFiles.Rows)
{
if ((row.FindControl("chkSelect") as CheckBox).Checked)
{
string lblfilepath = (row.FindControl("lblFilePath") as Label).Text;
zip.AddFile(lblfilepath, "Top Songs");


}
else
{
Response.Clear();
Response.BufferOutput = false;
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Length", fileLength);
Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
Response.TransmitFile(filePath);
Response.Flush();
}


}
Response.Clear();
Response.BufferOutput = false;
string zipName = String.Format("Top Songs - {0}.zip", fileName);
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "attachment; filename=" + zipName);
zip.Save(Response.OutputStream);
Response.End();

}
}

}
}
}
Ankit 71 9-Oct-14 1:36am View    
This is HTML code

<div style="font-family: Arial, Helvetica, sans-serif; font-size: x-large; margin-left:10px;">Top 30
<asp:Label ID="lbtitle" runat="server" Text=""> Songs


</div><br />
<div class="song">
<asp:GridView ID="gvUploadedFiles" runat="server" AutoGenerateColumns="False"
DataKeyNames="id" RowStyle-BackColor="#A1DCF2" Font-Names = "Arial" Font-Size = "10pt"
HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
BackColor="White" BorderColor="#CCCCCC" BorderStyle="None"
BorderWidth="1px" CellPadding="3" Height="75px" AllowPaging="True"
onpageindexchanging="OnPaging">
<HeaderStyle Font-Bold="true" BackColor="#ff6600" BorderColor="#f5f5f5"
ForeColor="White" />
<columns>

<asp:BoundField DataField="songname" HeaderText="FileName"
ControlStyle-Width="250" />

<asp:TemplateField>
<itemtemplate>

<object type="application/x-shockwave-flash" data="dewplayer-vol.swf?mp3=AdminPanel/SongUploads/<%# Eval("songname") %>"
width="240" height="20" id="dewplayer">
<param name="wmode" value="transparent" />
<param name="movie" value="dewplayer-vol.swf?mp3=AdminPanel/SongUploads/<%# Eval("songname") %>"/>





<%--<asp:TemplateField>
<itemtemplate>
<div style="padding: 4px 10px 10px 10px;">
<asp:CheckBox ID="chkSelect" runat="server" style="float:none; Height:15px; Width:15px;"/>
<asp:Label ID="lblFilePath" runat="server" Text='<%# Eval("FilePath") %>' Visible="false">
</div>

--%>

<asp:TemplateField>
<itemtemplate>

<asp:LinkButton ID="lnkDownloadMe" runat="server" Text="Download"
OnClick="lnkDownloadMe_Click" />




<footerstyle backcolor="White" forecolor="#000066">

<HeaderStyle BackColor="#006699" ForeColor="White" Font-Bold="True"></HeaderStyle>

<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />

<rowstyle forecolor="#000066">
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<sortedascendingcellstyle backcolor="#F1F1F1">
<sortedascendingheaderstyle backcolor="#007DBB">
<sorteddescendingcellstyle backcolor="#CAC9C9">
<sorteddescendingheaderstyle backcolor="#00547E">
Ankit 71 11-Jul-14 7:10am View    
unhandled exception has occured in your application. if you click Continue,the application will ignore this error and attempt to continue. If you click quit . the application will clise immidiately

Load report failed.
Ankit 71 8-May-14 3:36am View    
my code is: SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["sst"].ToString());
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from mastertable ", con);
DataSet ds = new DataSet();

da.Fill(ds);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
con.Close();
now i show the record on that field that i have selected,, but all the users that lies in that table not the login user.