|
Yeah, I was thinking that too...could i use an iframe to display the excel file? I still have to get the filename from the database...let me try it this way and hopefully I'll get it working...
|
|
|
|
|
yeah, that would work, I think.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Me again...I've implemented the iframe control, now I'm getting the following error from the browser:
) expected.
Here's the tag:
Am I missing something?
|
|
|
|
|
I think you want = instead of #.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
I use this code to save name of a picture in a table in database.file uploaded on a server but the name of that picture don't save on a database.
please help me.
protected void uploade_Click(object sender, EventArgs e)<br />
{<br />
if (uploadetest.HasFile == false)<br />
{<br />
uploadedetail.Text = "plese select youre file";<br />
}<br />
else<br />
{<br />
string filepath = Server.MapPath("~/pic/" + uploadetest.FileName);<br />
uploadetest.SaveAs(filepath);<br />
string FileName = string.Empty;<br />
FileName = uploadetest.PostedFile.FileName.Substring(uploadetest.PostedFile.FileName.LastIndexOf('\\'));<br />
<br />
<br />
string insertsql="INSERT INTO stt (picture) VALUES (@FileName)";<br />
SqlConnection con = new SqlConnection(connectionString);<br />
SqlCommand cmd = new SqlCommand(insertsql, con);<br />
con.Open();<br />
cmd.CommandText = insertsql;<br />
con.Close();<br />
<br />
}<br />
}
|
|
|
|
|
bbc_sh wrote: string FileName = string.Empty;
Why, when you're about to reset it ?
bbc_sh wrote: uploadetest.PostedFile.FileName.Substring(uploadetest.PostedFile.FileName.LastIndexOf('\\'));
Use Path.GetFileName for this
bbc_sh wrote: string insertsql="INSERT INTO stt (picture) VALUES (@FileName)";
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(insertsql, con);
con.Open();
cmd.CommandText = insertsql;
con.Close();
you create a paraterised query, but never add your parameter value. Where did you think that the FileName string got passed to the SQL ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Also, your command is never actually executed against the database. You need to change this:
con.Open();<br />
cmd.CommandText = insertsql;<br />
con.Close();<br />
to this:
con.Open();<br />
cmd.CommandText = insertsql;<br />
cmd.ExecuteNonQuery();
con.Close();<br />
Also, as Christian mentioned, you need to set the parameter value:
<br />
cmd.Parameters.Add("@FileName", DbType.Varchar, 500);<br />
cmd.Parameters["@FileName"].Value = FileName;
|
|
|
|
|
I have the following templatefield in my gridview.
I wanted to show the value from my datasource in it but it doesnt show up, it shows error message:
Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.ListItem does not have a DataBinding event.
<asp:templatefield headertext="Activity Order" xmlns:asp="#unknown">
<itemtemplate>
<asp:dropdownlist id="ddorder" runat="server" datasourceid="SqlDataSource1">
<asp:listitem text="<%# Eval(" order")="" %>"="" value="<%# Eval(">
is there a way to show values in a dropdownlist?
thanks
|
|
|
|
|
Yes. However, not the way you're doing it. I think you need to use the itemdatabound event, find your control and bind it to a source there.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
If I have got my datasource set in my aspx page how do I set a value selected from that query to my dropdown
i have this
DropDownList dd = ((DropDownList)row.FindControl("ddorder"));
dd.DataValueField =
thats in my databound event but how do I set it to the field from the query. I'm not sure of the syntax.
In my aspx the other fields in the gridview are just set like normal bound fields
|
|
|
|
|
I have no idea, I'd never use that nasty 'set a data source in the presentation layer' stuff that MS has built in to ASP.NET in recent times.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Ok, if i set my datasource in the c# instead like:
SqlDataSource1.SelectCommand = "select field from table"
how do I reference a field from that?
|
|
|
|
|
I believe you set the DisplayMember property to the name of the column you want to show.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hi
sqldatasource does not have that attribute.
thanks anyway I will try the web.
cheers
|
|
|
|
|
No, the drop down list does.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Imagine this is my initial page DSIHome.aspx
I need to implement AJAX in existing project, my requirement is………
I have a menu with sub menus,, which is again generated dynamically (XML).
On clicking in any of the sub menus, I pass the argument to the URL , just like below
location.href="DSIHome.aspx?hdnfld=" + obj + "&catName="+ catName ;
this will initiate the postback and pass the values to the URL,
and I can retrieve the form content based on the URL values using QueryString,
my part here is to STOP postback,
i need to implment AJAX and stop the postback happening while clicking the sub menu
do u have any suggestion for this ?
winnie
|
|
|
|
|
The URL does not change when you use AJAX, so you need to rethink your whole approach. You could pass the values via the AJAX call and store them in jscript if you need them locally.
What's on the page, that is, what sort of navigation are you hoping to replace with AJAX ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
thanks for the quick reponse,
I havent found the method to solve the problem, i can take your suggestion using AJAX call, can you provide me with links, samples on how to implement that.
regards
winnie
|
|
|
|
|
Umm.... I asked you some questions, could you answer them ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
the page contains treeview and 2 datalist, the data on these controls is loaded based on the values on the URL,
as you said the values should be available locally ,
hope im conveying the problem in right words
regards
winnie
|
|
|
|
|
OK, you should use ASP.NET AJAX for this, which will just wrap everything for you. Trying to populate those controls using your own JS is a PITA. If you put everything in an update panel, it will just AJAX it for you.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
|
Hi Guys,
When i LogOut a user on my site a User is still able to hit the Back button in their browser and essentially view a logged in only page.
Ideal scenario would be for this page to send them to Login screen.
What would be the best way to stop this from happening?
FYI.
When a user logs in, i store a loggedIn value in a session variable.
On logout i reset this session to indicate the user is loggedOut.
I am using c# .net
Many Thanks.
|
|
|
|
|
You need to make sure the browser doesn't cache your page. If you hit refresh, does it go to the login page ? If so, this is your problem. Put Response.Cache.SetCacheability(HttpCacheability.NoCache) in your pages, preferably via a common base page ( the place where you check if the session is set is a good place to do it.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
HI friends, this question is regarding Crystal Reports in VS 2005
My report here is attached to a SP. I'm trying to pass parameters but it raises an error:
Procedure or function 'sp_wfsAppByCounsReport' expects parameter '@StartingDate', which was not supplied.
Here is my code, I'm passing the parameter. I can even trace it and the rdDocument variable has them attached after the SetParameteValue....why the report is not sending them to the SP???
Here is my code:
protected void Page_Load(object sender, EventArgs e)
{
DateTime dtStartingDate = DateTime.Parse(DateTime.Today.Month.ToString() + "/" + "1" + "/" + DateTime.Today.Year.ToString());
ConnectionInfo ciLogin = new ConnectionInfo();
ciLogin.ServerName = "myserver.com";
ciLogin.DatabaseName = "mydb";
ciLogin.UserID = "dbuser";
ciLogin.Password = "mypass";
TableLogOnInfo tbLogonTable = new TableLogOnInfo();
tbLogonTable.ConnectionInfo = ciLogin;
ReportDocument rdMonthReport = new ReportDocument();
rdMonthReport.Load(Server.MapPath("couns-month.rpt"));
rdMonthReport.SetParameterValue("@StartingDate", dtStartingDate);
rdMonthReport.SetParameterValue("@EndingDate", DateTime.Today);
foreach (CrystalDecisions.CrystalReports.Engine.Table tbTable in rdMonthReport.Database.Tables)
{
tbTable.ApplyLogOnInfo(tbLogonTable);
}
CrystalReportViewer.ReportSource = rdMonthReport;
CrystalReportViewer.RefreshReport();
}
Any help is appreciated!!
|
|
|
|