|
i have one gridview in my application ihave filled my gridview with the values from database now i want title column to be hyperlink and when i click on this column value the file which is in the server system at the specified location i.e., feedback path to be downloaded in the client system
below is the code for filling gridview with database values
-----------------------------------------------------------
DataSet ds = new DataSet();
SqlConnection cn = new SqlConnection("Persist Security Info=False;User ID=sa;Initial Catalog=Mtlinecount;Data Source=Ms05");
SqlDataAdapter da = new SqlDataAdapter("select h.Sitename,Title,feedbackpath,Createddate from QAfeedbackDetails qa inner join hospital h on h.siteid=qa.siteid where qa.Siteid=h.siteid and createddate between '" + txtFromDate.Text + "'and '" + txtToDate.Text + "'", con);
da.Fill(ds, "QAFeedbackDetails");
gvFeedback.DataSource = ds.Tables[0];
gvFeedback.DataBind();
thank in advance for u r help
|
|
|
|
|
Use HtmlAnchor Tag if you want to download file.
try following code in ItemTemplate
<a href='<%# Eval("fieldName")%>'>Download</a>
please don't forget to vote on the post that helped you.
|
|
|
|
|
|
hi,
I am using the below coding to thumbnail creation, this coding is saving both the original image and the thumbnail image. I don’t want the original image. How to delete the original image. Please help me.
private void btnUpload_Click(object sender, System.EventArgs e)
{
// Initialize variables
string sSavePath;
string sThumbExtension;
int intThumbWidth;
int intThumbHeight;
// Set constant values
sSavePath = "images/";
sThumbExtension = "_thumb";
intThumbWidth = 160;
intThumbHeight = 120;
// If file field isn’t empty
if (filUpload.PostedFile != null)
{
// Check file size (mustn’t be 0)
HttpPostedFile myFile = filUpload.PostedFile;
int nFileLen = myFile.ContentLength;
if (nFileLen == 0)
{
lblOutput.Text = "No file was uploaded.";
return;
}
// Check file extension (must be JPG)
if (System.IO.Path.GetExtension(myFile.FileName).ToLower() != ".jpg")
{
lblOutput.Text = "The file must have an extension of JPG";
return;
}
// Read file into a data stream
byte[] myData = new Byte[nFileLen];
myFile.InputStream.Read(myData,0,nFileLen);
// Make sure a duplicate file doesn’t exist. If it does, keep on appending an
// incremental numeric until it is unique
string sFilename = System.IO.Path.GetFileName(myFile.FileName);
int file_append = 0;
while (System.IO.File.Exists(Server.MapPath(sSavePath + sFilename)))
{
file_append++;
sFilename = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName)
+ file_append.ToString() + ".jpg";
}
// Save the stream to disk
System.IO.FileStream newFile
= new System.IO.FileStream(Server.MapPath(sSavePath + sFilename),
System.IO.FileMode.Create);
newFile.Write(myData,0, myData.Length);
newFile.Close();
// Check whether the file is really a JPEG by opening it
System.Drawing.Image.GetThumbnailImageAbort myCallBack =
new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
Bitmap myBitmap;
try
{
myBitmap = new Bitmap(Server.MapPath(sSavePath + sFilename));
// If jpg file is a jpeg, create a thumbnail filename that is unique.
file_append = 0;
string sThumbFile = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName)
+ sThumbExtension + ".jpg";
while (System.IO.File.Exists(Server.MapPath(sSavePath + sThumbFile)))
{
file_append++;
sThumbFile = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) +
file_append.ToString() + sThumbExtension + ".jpg";
}
// Save thumbnail and output it onto the webpage
System.Drawing.Image myThumbnail
= myBitmap.GetThumbnailImage(intThumbWidth,
intThumbHeight, myCallBack, IntPtr.Zero);
myThumbnail.Save (Server.MapPath(sSavePath + sThumbFile));
imgPicture.ImageUrl = sSavePath + sThumbFile;
// Displaying success information
lblOutput.Text = "File uploaded successfully!";
// Destroy objects
myThumbnail.Dispose();
myBitmap.Dispose();
}
catch (ArgumentException errArgument)
{
// The file wasn't a valid jpg file
lblOutput.Text = "The file wasn't a valid jpg file.";
System.IO.File.Delete(Server.MapPath(sSavePath + sFilename));
}
}
}
public bool ThumbnailCallback()
{
return false;
}
prakash
|
|
|
|
|
You don't have to delete the file. Just don't create it.
Create a MemoryStream object from the byte array, and load the image from that.
jai 123 wrote: myFile.InputStream.Read(myData,0,nFileLen);
That's not a secure way to read the data. The Read method returns an integer that tells you how many bytes where actually read, and this can be less than the number of bytes requested. You have to loop until you have read all bytes, or until the value returned is zero.
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
Hi All,
Can any one tell me whts difference between ASP.NET 1.x and ASP.NET 2.x.
Thanks in Advance.
|
|
|
|
|
Respected All,
I have created 4-5 reports in asp.net with c#.
this all reprots r working fine on local host,.
but wn i have uploded tht reports some error is there in repot and its not working..
Error Reports r like:
---------------------------------------------------------------------------------
Server Error in '/fotoAlumamit/bk' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customerrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customerrors> tag should then have its "mode" attribute set to "Off".
<configuration>
<system.web>
<customerrors mode="Off">
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customerrors> configuration tag to point to a custom error page URL.
<configuration>
<system.web>
<customerrors mode="RemoteOnly" defaultredirect="mycustompage.htm">
-------------------------------------------------------------------------------
sp please can anyone help me tht how can i fix tht error
or wt settings hv to be made in report viwer to mk thm enable online..
waiting for reply.
Thanx in advance.
Jigar Badgujar.
BeBadgujar
|
|
|
|
|
Hi all,
1. Is there any benefit in using login control when we are using our own database to store login creadentials.
2. Can we use our own database to implement roles
Thanks in advance...
|
|
|
|
|
hi all
In my application there several web pages the last page is payment page(credit card) which is a secure page that is its url is https. but when i click on any link to return to other pages its still shows https.
although all links accept the payment page is http. Then also it shows https once i visit the payment page and try to click a link for other pages.
so how to remove that https to http for other pages.
Pl help
Regards
Prakash Mishra(Banglore,India)
|
|
|
|
|
Prakash_Mishra wrote: but when i click on any link to return to other pages its still shows https.
Append http to the links present in that secure page instead of redirecting like /page.aspx
|
|
|
|
|
Thanks a lot
Prakash Mishra(Banglore,India)
|
|
|
|
|
You are using relative url i.e. "..\otherpages.asp" so after you visit the https page other consequent pages will be assumed to be of the same protocol will be used last (https).
Use absolute url (e.g. "http://www.codeproject.com/otherpage.asp" ) on the links of other pages.
Cheers
Raz
/*
Ghazi Hadi Al Wadi, PMP, ASQ SSGB, DBA
*/
|
|
|
|
|
Thanks a lot
Prakash Mishra(Banglore,India)
|
|
|
|
|
hi friends
i have two columns in datagrid
now i need to set width of the second column..
how can i set width second column..
regards
saravanan
Known Is Drop.Unknown Is Ocean
|
|
|
|
|
Give second column width using
<asp:BoundField HeaderStyle-Width ="6%" ></asp:BoundField>
|
|
|
|
|
DataGrid1.Columns[1].Width ?
|
|
|
|
|
Hi,
U can use following methode.
e.Row.Cells[2].Width = Unit.Pixel(100);
Hope this wil help u
Regrds
Lijo
|
|
|
|
|
hi friends
this is my code:
<asp:datagrid id="DataGrid1" runat="server"
="" height="210px" width="276px" backcolor="White" bordercolor="White" gridlines="None">
<columns>
<asp:templatecolumn>
<itemtemplate>
<asp:templatecolumn headertext="">
<itemtemplate>
<%# DataBinder.Eval(Container.DataItem,"comment")%>'
string ConStr = ConfigurationManager.AppSettings["ConnectionString"].ToString();
SqlConnection conn = new SqlConnection(ConStr);
conn.Open();
//SqlDataAdapter adap = new SqlDataAdapter("select rowid,Fromname,Toname,Comments,Imagename,mailid,Type,sflag,Datess from tbl_bday ",con);
SqlDataAdapter adap = new SqlDataAdapter("select image,comment from tbl_registration", conn);
DataSet ds = new DataSet();
adap.Fill(ds);
//DataGrid1.Columns[1].ItemStyle.Width = 10;
DataGrid1.Columns[0].ItemStyle.Width= 12;
DataGrid1.DataSource = ds;
DataGrid1.DataBind();
i tried but not working
can u help me?
regards
saravanan
Known Is Drop.Unknown Is Ocean
|
|
|
|
|
hi,
u can write the code which i gave u previously in rowdatabound event of ur grid.it wil work fine.
Regrds
Lijo
|
|
|
|
|
I wanted to know what kind of database would help me around for building a website which includes search. I will be using ASP.NET for my website and i am not sure what are the parameters which needs consideration before selecting a database.
Thanks n Regards
Nitin Goel
|
|
|
|
|
SQL Server is Microsoft's Database solution to medium to large and Enterprise level project's. I suggest anyone to use this for a ASP.NET website.
niting85 wrote: what are the parameters which needs consideration before selecting a database.
I guess this depends on the size of the project, Project requirement's, resource availability, cost and other technical factor's such as Whether Database server provides a GUI tool for Database Designing, Does it provides high Security System, and Does it provides extensive sql library functions, Referential Integrity, Triggers, Cursors, Views....
Regards - J O H N -
|
|
|
|
|
SQL Server works pretty well, a good point is that you can perform search as well on embedded Word / PDF documents.
Mmm... do you want a search on your DB, or a search in your site? If it's a search in your site you can think about using msn or google search (you can customize to search in your site), if it's an intranet another possibility is to use Sharepoint 2007 indexing capabilities (don't need to develop your site using sharepoint ), take a look at:
http://msdn.microsoft.com/msdnmag/issues/07/09/WebSearch/default.aspx?loc=en[^]
HTH
Braulio
/// -------------------------
Braulio Díez
tipsdotnet.com
/// -------------------------
|
|
|
|
|
Hi,
I have a combobox in my application on which i want to validate A-Z character entry on combo_itemsRequested Event
I dragged a regular Expresion Validator and set its property as
<asp:RegularExpressionValidator ID="revTxtdep" ValidationExpression="^(\w[a-zA-Z]+)$" Display="None" ControlToValidate="txtDeparture" runat="server" ErrorMessage="Invalid Characters Entered" SetFocusOnError="true" ValidationGroup="Search"></asp:RegularExpressionValidator>
But the probkem is that it doesnt work and i get a error stating
A potentially dangerous Request.QueryString value was detected from the client (text="aa
|
|
|
|
|
Hai all,
In my application i am using System.Net.Mail for sending mail.
for that i have used the code as given below.
MailMessage mail = new MailMessage();
MailAddress To = new MailAddress("lijorajan2004@gmail.com");
mail.To.Add(To);
mail.Body = "Hai";
MailAddress From = new MailAddress("lijo@ourdomain.com");
mail.From = From;
SmtpClient client = new SmtpClient("smtp.myserver.com");
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Host = "hostname";//host name is our remote ip address
client.UseDefaultCredentials = false;
client.Send(mail);
here the problem is i am able to send mail to my lijo@mydomain.com(it is our own domain).but i am not able to send mail to other domain(lijorajan2004@gmail.com);
here i am getting error like "Mailbox unavailable. The server response was: 5.7.1 Unable to relay for lijorajan2004@gmail.com"
plse help me.
Thanks in advance.
Regds
Lijo
|
|
|
|
|
Your server is not allowed to relay messages that are not (either from one of it's users or to one of it's user's inbox)
So to send the message either the sender or the receiver has to be from the server's (i.e. me@myserver.com)
Nothing wrong with your code. Just the test email addresses need to be reviewed.
Cheers
Raz
/*
Ghazi Hadi Al Wadi, PMP, ASQ SSGB, DBA
*/
|
|
|
|