|
why dont you place it in a location common to everybody, even in database will do. In this case you are leaving out the unnecessary bugs that comes with multiple occurrence of the same file.
|
|
|
|
|
Yes I understand what you are saying -
however I'm using flash code in my application that requires as input the name of an xml file with the data the flash application needs. I want to update this data in the xml file one time per day.
So a file is required in this case - but I'm not sure of the best way to update this file only once per day.
|
|
|
|
|
You could always manage this with a scheduled application (say, a console or winforms app scheduled to run through Task Scheduler).
|
|
|
|
|
hey all.. i need a guidence to my problem im facing
i want to display data in gridview binded to a sql datasource
but the problem part is i want to bind a field of that datasource to a dropdownlist and when a item is selected in that dropdownlist then correcposnding to that data will be displayed in gridview...
i have done the binding of datasource and gridview... but not of cropdownlist...plz help buddies... i'll be very grateful ... thanks in advance
here is my code which im using
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{ con = new SqlConnection("Data Source=.;Initial Catalog=abc;Integrated Security=True");
con = new SqlConnection("Data Source=.;Initial Catalog=abc;Integrated Security=True");
cmd = new SqlCommand("select * from salescounts where ='"+DropDownList1.Text+"'", con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
GridView1.DataSource = dr;
GridView1.DataBind();
Label1.Text = "Result found:" + GridView1.Rows.Count;
}
else
{
Label1.Text = "not found";
}
con.Close();
}
modified on Sunday, July 26, 2009 12:51 PM
|
|
|
|
|
Just Try this one
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DataSet Ds=new DataSet();
con = new SqlConnection("Data Source=.;Initial Catalog=abc;Integrated Security=True");
cmd = new SqlCommand("select * from salescounts where ='"+DropDownList1.Text+"'", con);
SqlDataAdapter DA = new SqlDataAdapter(cmd);
DA.Fill(ds);
if(Ds.Tables[0].Rows.Count>0)
{
GridView1.DataSource = ds;
GridView1.DataBind();
Label1.Text = "Result found:" + GridView1.Rows.Count;
}
else
{
Label1.Text = "not found";
}
con.Close();
}
Quick Suggestion :
solo_gaurav wrote: cmd = new SqlCommand("select * from salescounts where ='"+DropDownList1.Text+"'", con);
Never Execute SQL Query like this from UI level. It will causes SQL Injection. Always used Parameterized query / Stored Procedure .
Thansk
|
|
|
|
|
hello abhijeet...corrected my code but tell me solution of my problem.. i.e how can i display data from datasource in tabular form when i select a bounded field of same data source in dropdownlist.. plz dear help me... thanks in advance
|
|
|
|
|
solo_gaurav wrote: ow can i display data from datasource in tabular form when i select a bounded field of same data source in dropdownlist.
Gaurav,
I am not clear about your problem. Can you please explain in details ?
|
|
|
|
|
dont worry sir i did it myself ... thanks for support and co-operation..
|
|
|
|
|
That's Cool
|
|
|
|
|
solo_gaurav wrote: cmd = new SqlCommand("select * from salescounts where ='"+DropDownList1.Text+"'", con);
As the other poster had mentioned, this opens you up for a potential SQL Injection attack. I recommend reading SQL Injection Attacks and Some Tips on How to Prevent Them[^] by Colin Mackay on this site.
If you could shed some light on what are actual data values of DropDownList1.Text would be helpful. Your trouble might be what is being generated as the SQL string and causing it not to bind the data.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
my system did not contain machine.config is not there in the bellow path. How to create machine.config in my system ?.is it mandatory to run asp.net
project or not.
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322(gacutil.exe and regsvcs.exe) are there in that location.
|
|
|
|
|
Ramesh Reddy11111 wrote: my system did not contain machine.config is not there in the bellow path
It is never supposed to be there in the path you mentioned but should be present at the location below:
C:\Windows\Microsoft.NET\Framework\v1.1.4322\CONFIG
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I have a wizard control in my form. In one of the steps there is a file upload control. If the user uploads a file using the browse button and then he clicks on Next button instead of Upload button, the textbox gets cleared.
Is there anyway to retain the string entered in fileupload control textbox so that the user need not enter again? Please help.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
only way is to place the upload file code in the next button as well, check if file is there and if so then upload it while the user is clicking on Next button
|
|
|
|
|
Thanks for the reply. But again, i have to either repeat the code or write the code in a function and call it, which I think is redundancy of code. So what I am thinking is, I can save the file name in the viewstate while uploading. So if viewstate is null, then I can disable the nextbutton else enable it.
So while loading the tab itself, it is disabled since there is no filename in viewstate. So the user has to upload the file.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
I am not a very fond of using ViewState, as it is transferred through the request/response body all the time, hence increasing the size of the data transferred.
Anyways, nice to hear that you got the solution.
|
|
|
|
|
Hi,
Although I have writing C# applications for several years, I only recently launched my first ASP.Net website. The site is run by an internal database in the App_Date folder. The Login page defines a group of Session variables that are retrieved, as needed, from concurrent pages. The Login page works perfectly and loads the Session information to the next page> That page, for security purposes, requires that an additional Password (called Signature) is submitted before it is allowed to advance. The problem is: the next page fails to load because the Session variables needed to load the next page have been nulled, as reported by the following error page:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 456:
Line 457: //Get Session Variables
Line 458: FName = Session["FName"].ToString(); /////This line is highlighted. Changing the order of the variables always reproduces the error on the same line number of the code (458)./////
Line 459: userName = Session["Name"].ToString();
Line 460: site = Session["Site"].ToString();
Source File: \\frigga\home\users\web\b157\\QueryLogger\Alerts.aspx.cs Line: 458
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Alerts.Page_Load(Object sender, EventArgs e) in \\frigga\home\users\web\b157\hy.softdynamics\QueryLogger\Alerts.aspx.cs:458
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
Now, I am sure that the first page pass is working correctly because some of the data displayed on that page is the result of Session value queries to the database. That leaves the following question: What would cause the Session values to be nulled when passing from the second to the third page? .... and could this the result of improper >Net framework on the hosting server? Or perhaps anything else? Any help would be greatly appreciated.
Pat
|
|
|
|
|
Pat,
Where did you stored data in the Session? Your application is running from VS or IIS ? What is the session mode ?
Always check session null before read the value from it.
if(Session["FName"] !=null)
FName = Session["FName"].ToString();
|
|
|
|
|
Yes, thank you for pointing that out Abhijit. I will make that change immediately (I was in too much of a hurry.. ). But the problem is still there. The server is hosted by a hosting service (Hypermart), so I am not sure about the server, but I think it is IIS. I'll try to find out and let you know....Pat
|
|
|
|
|
I think you are trying to retrieve the Session variable after clearing out it.
Check like this
if(Session["Variable"] == null)
{
}
else
{
}
|
|
|
|
|
Just guessing, but this [^]could be a reason.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi,
I am using the following code to retrieve the file name of a pdf document stored in a database. Once I have the string, I have the PDF's stored in a folder under App_Data. I need it to load on the clients computer using their internal PDF reader (whatever that might be....usually Adobe Reader). I know that all I need to do is to point to the Pdf for it to open on the client side, but since it is different each time depending on the line that was selected from the grid, how do I pass the value? Or is there a better way to do this?
CS Code
//Define the row and cell
int theRow = Convert.ToInt32(e.CommandArgument);
int theCell = 6;
//Get the Row information
GridViewRow gvr = GridViewResults.Rows[theRow];
//Get the information from the cell
this.thePdf = gvr.Cells[theCell].Text;
//Call Clients PDF reader via a Hyperlink ?? OR ??
ASPX Code
<%--Gridview--%>
<asp:GridView ID="GridViewResults" runat="server" CssClass="gridViewSpecs"
HeaderStyle-Height="30px" Height="100px" Width="770px" BackColor="White"
RowStyle-Height="25px" EnableViewState="true"
onrowcommand="GridViewResults_RowCommand"
onselectedindexchanged="GridViewResults_SelectedIndexChanged" >
<RowStyle Height="25px" />
<HeaderStyle Height="30px"></HeaderStyle>
<HeaderStyle BackColor="#CCCCCC" />
<Columns >
<asp:CommandField HeaderImageUrl="~/Graphics/adobe2.PNG" ShowSelectButton="True" />
</Columns>
</asp:GridView>
Thank You, Pat
|
|
|
|
|
Just give simple hyperlink of that PDF for download, which allows the End user either Sava or Open the Pdf.
You can also have a look into this article Downloading Files
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
OK Abhijit,
Sorry about the delayed response. I had to leave for a bit.
Thank you for the insight, but as I said in the post, it is not a hard coded link. There are over 1500 pdf's that can be called, depending on the results of the search. How do I pass the variable for the correct one in the form of a link so it can be accessed and clicked on by the Client? If you can, please supply a code sample that I can work from that will coordinate with the actual code that I supplied in the original request.
Thank You
Regards, Pat
|
|
|
|
|
From your first post.
PDTUM wrote: //Get the information from the cell
this.thePdf = gvr.Cells[theCell].Text;
Does it contain the actual pdf file path ?
You need to bind the pdf path at runtime only.
|
|
|
|