|
And this is code for Order.aspx. Incorrect syntax that I can't find. That makes me really worried!
<pre>
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" Title="Untitled Page" AutoEventWireup="False" %>
<%@ Register Src="~/Manage/Order.ascx" TagName="Order" TagPrefix="uc1" %>
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not IsPostBack Then
ddlOrder.DataBind()
End If
Session("OrderNum") = ddlOrder.SelectedValue
End Sub
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
Choose an order to display:
<asp:DropDownList ID="ddlOrder" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource1" DataTextField="OrderNum"
DataValueField="OrderNum">
</asp:DropDownList>&nbsp;
<asp:LinkButton ID="LinkButton1" runat="server"
PostBackUrl="~/Manage/PrintOrder.aspx">Print this page</asp:LinkButton>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ProjectConnectionString %>"
SelectCommand="SELECT OrderNum FROM Order ORDER BY OrderNum">
</asp:SqlDataSource><br /><br />
<uc1:Order ID="Order1" runat="server" />
</asp:Content>
</pre>
|
|
|
|
|
I guess I would add a space after the word Order.
I guess that you concatenate strings like
String query = String.Empty;
query += "Select * FROM Order";
query += "Where Value = 1";
if you would check the content of the string query it would read:
Select * FROM OrderWhere Value = 1
Maybe this makes your problem clear.
|
|
|
|
|
how to generate excel that have validation list .
|
|
|
|
|
You ought to be little more descriptive to aide others in help and troubleshoot with your problem on hand with an elegant expedited solution.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
Hi
Thanks for replying.
I want the Excel to have a drop-down list.
I have a string of xml like this:
xml.txt
<br />
<?xml version="1.0"?><br />
<?mso-application progid="Excel.Sheet"?><br />
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"<br />
xmlns: o ="urn:schemas-microsoft-com:office:office"<br />
xmlns: x ="urn:schemas-microsoft-com:office:excel"<br />
xmlns:ss ="urn:schemas-microsoft-com:office:spreadsheet"<br />
xmlns:html ="http://www.w3.org/TR/REC-html40"><br />
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"><br />
<Author>Mee</Author><br />
<LastAuthor>Mee</LastAuthor><br />
<Created>2008-05-07T06:18:28Z</Created><br />
<Company>Ram</Company><br />
<Version>11.5606</Version><br />
</DocumentProperties><br />
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"><br />
<WindowHeight>8700</WindowHeight><br />
<WindowWidth>12315</WindowWidth><br />
<WindowTopX>0</WindowTopX><br />
<WindowTopY>120</WindowTopY><br />
<ProtectStructure>False</ProtectStructure><br />
<ProtectWindows>False</ProtectWindows><br />
</ExcelWorkbook><br />
<Styles><br />
<Style ss:ID="Default" ss:Name="Normal"><br />
<Alignment ss:Vertical="Bottom"/><br />
<Borders/><br />
<Font x:CharSet="222"/><br />
<Interior/><br />
<NumberFormat/><br />
<Protection/><br />
</Style><br />
</Styles><br />
<Names><br />
<NamedRange ss:Name="x" ss:RefersTo="=Sheet2!R1C1:R2C1"/><br />
</Names><br />
<Worksheet ss:Name="Sheet1"><br />
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1"<br />
x:FullRows="1"><br />
<Row><br />
<Cell><Data ss:Type="String">data</Data></Cell><br />
</Row><br />
</Table><br />
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"><br />
<Selected/><br />
<Panes><br />
<Pane><br />
<Number>3</Number><br />
<ActiveRow>2</ActiveRow><br />
</Pane><br />
</Panes><br />
<ProtectObjects>False</ProtectObjects><br />
<ProtectScenarios>False</ProtectScenarios><br />
</WorksheetOptions><br />
<DataValidation xmlns="urn:schemas-microsoft-com:office:excel"><br />
<Range>R2C1</Range><br />
<Type>List</Type><br />
<Value>x</Value><br />
</DataValidation><br />
</Worksheet><br />
<Worksheet ss:Name="Sheet2"><br />
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="2" x:FullColumns="1"<br />
x:FullRows="1"><br />
<Row><br />
<Cell><Data ss:Type="Number">1</Data><NamedCell ss:Name="x"/></Cell><br />
</Row><br />
<Row><br />
<Cell><Data ss:Type="Number">2</Data><NamedCell ss:Name="x"/></Cell><br />
</Row><br />
</Table><br />
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"><br />
<Panes><br />
<Pane><br />
<Number>3</Number><br />
<RangeSelection>R1C1:R2C1</RangeSelection><br />
</Pane><br />
</Panes><br />
<ProtectObjects>False</ProtectObjects><br />
<ProtectScenarios>False</ProtectScenarios><br />
</WorksheetOptions><br />
</Worksheet><br />
</Workbook>
I want to convert this string to excel(*.xls) .
I try this :
<br />
f = New FileInfo("c:\test.xls")<br />
f.Delete()<br />
s = f.CreateText<br />
<br />
s.WriteLine('string from xml.txt')<br />
s.Close()<br />
<br />
<br />
<br />
<br />
This code can generate the excel file but when i import excel's data
by this code:
<br />
Dim ds As New DataSet<br />
Dim Olecn As OleDb.OleDbConnection<br />
Dim da As OleDb.OleDbDataAdapter<br />
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _<br />
"Data Source=" & FilePath & ";" & _<br />
"Extended Properties=""Excel 8.0;HDR=Yes"""<br />
Olecn = New OleDb.OleDbConnection(strConn)<br />
Olecn.Open()<br />
da = New OleDb.OleDbDataAdapter("SELECT * FROM [" + SheetName + "$]" ), strConn)<br />
Try<br />
da.Fill(ds)<br />
Catch<br />
<br />
Finally<br />
Olecn.Close()<br />
End Try<br />
Return ds<br />
This not works.
I can't import data that create from this excel.
I don't know why .
Thanks in advance
|
|
|
|
|
from page 1.aspx, when the user clicks a link, page 2.aspx appears (a popup window).
this popup (page 2.aspx) has no addressbar or toolbar.
i am getting users emial address and few more detail from this page(page 2.aspx).
i have this code in page 2.aspx code behind.
<br />
If Not Page.IsPostBack Then<br />
' Save the referrer Url<br />
ViewState("ReferrerUrl") = Request.UrlReferrer.ToString()<br />
End If<br />
what happens is, whenever i try this link from IE i am getting this errro:
Object reference not set to an instance of an object.
Line 18: If Not Page.IsPostBack Then
Line 19: ' Save the referrer Url
Line 20: ViewState("ReferrerUrl") = Request.UrlReferrer.ToString()
Line 21: End If
it shows that line 20 has error.
but this same codes works fine with Firefox.
why IE is giving me the erorr?
|
|
|
|
|
Meax wrote: Object reference not set to an instance of an object.
It means your Request.UrlReferrer is null . Since it's a popup, IE don't get the referrer. I am not sure why this works with firefox and not with IE. HTTP referrer is unreliable and many firewalls can strip that out. Alternatively check you are getting referrer using JS. Or use window.opener.location which gives opener window's location (referrer).
|
|
|
|
|
Hello,
I know that Focus is a client-side event but is there a way to call a server-side event in my code-behind file in reponse to focus change in a DropDownList? Something like,
1. Handle the focus in the javascript in the .aspx file
2. call a server-side method inside that javascript event handler?
Is that possible at all? If yes a code sample would help, becasue whatever I tried did not seem to work.
THanks for reading!
|
|
|
|
|
You can force a postback by examining the javascript that does it in general. Or you can make an AJAX call.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello,
I need to capture the user response to a confirm dialog. if the user clicks cancel, the postback is cancelled and I want to do something else even if its a cancel. I just use the clientscript.registerstartupscript to show a confirm dialog. What should I be doing to accomplish what i wish to?
|
|
|
|
|
if you are using a button...
OnClientClick="return confirm('Sure??');"
This will prevent the postback if user selects cancel
and will submit the form if the user selects ok
Alexei Rodriguez
|
|
|
|
|
i have a repeater in my asp page and there is a bool record in my database lets call it photo
if its true it means user uploaded a photo so user photo must be shown in imgPhoto control
but if its false it means default photo must be shown
anyone can help me to do it?
here is my code:
<asp:Repeater ID="RepeaterComments" runat="server" DataSourceID="SqlDatSrcComments">
<ItemTemplate>
<table style="width: 100%" cellspacing="0" cellpadding="0">
<tr>
<td style="width: 50%;text-align: left;background-color: #F0F0F0;">
<asp:Image ID="imgPhoto" runat="server"
ImageUrl='<%# Eval("UserID", "~/Photos/Users/Small/{0}.jpg") %>'
ToolTip='<%# Eval("Nickname") %>' Height="16px" Width="16px"/>
<asp:HyperLink ID="hypLnkCommentUsername" runat="server" CssClass="InfoLink"
NavigateUrl='<%# Eval("UserID", "~/Profile.aspx?UserID={0}") %>'><%# Eval("Nickname") %></asp:HyperLink>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
|
|
|
|
|
<% if (whatever) {%>
emit your HTML here
<% } %>
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Try this:
ImageUrl = '<%# IIF (Eval("boolColumn"), Eval("UserID", "~/Photos/Users/Small/{0}.jpg"), "DefaultImageURL") %>'
Alexei Rodriguez
|
|
|
|
|
Won't this only work if the code behind is VB ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I guess, im not sure if IIF is supported in c#, but there must be something similar, isnt there?
I just hope this guy gets the idea
If he is using c#, he will have to find something similar
But im not sure what language he is using
How can you tell he is using c#?
Alexei Rodriguez
|
|
|
|
|
(boolean expression) ? if true : if false is in C#. I don't know what he's using, I'd hope the syntax I am showing worked for both, I do try to use language agnostic constructs where I can.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi
I have 2 tables in database as follows:
table1:
id name state id
1 aaa 1,2
2 bbb 1,3
table2:
id state
1 ak
2 ny
3 jk
so the problem is that I want to display all the data of "table1" in a gridview and in place of "state id" I want to display "statename", for example in place of "1,2" I want to display "ak,ny".
How to do this?
Please help me .
Thanks
|
|
|
|
|
Are you asking for help with building an SQL statement?
If so, it might look like this:
Select t1.*, t2.State as StateAcro from table1 as t1 inner join table2 as t2 on (t1.id=t2.id)
Otherwise, could you elaborate a bit more?
|
|
|
|
|
Hi
Thanks for replying.
ids in table1 are seperated with commas so t1.id=t2.id will not work.
I need asp.net code to display table1 values as I explained in my previous post.
Thanks
|
|
|
|
|
Seems to me like you need to design your db better in future ( a joining table would have made this doable in the SQL ).
You can read your array of state names and Ids, then write a data binding statement that passes the id string to the code behind, where you use the split method and a string builder to build a string that contains the state abbreviations.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Christian
Thanks for reply
Actually I am displaying names of states in a checkbox list and after submitting the form, storing selected checkbox stateids in database with stateids seperated by comma as in table1.
If you have any working example or else any suggestion, please send it.
Thanks
|
|
|
|
|
What I said. A joining table joins data where there's an arbitrary number of joins
id name state id
1 aaa 1,2
2 bbb 1,3
table2:
id state
1 ak
2 ny
3 jk
table3:
nameId, stateId
1, 1
1, 2
2, 1
2, 3
then table 1 loses the stateID column.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi,
i have a to add a reference dll to my asp.net web application. i'm going to solution explorer and clicking on add reference and selecting a dll for reference. but i'm not getting references folder in the solution explorer. can any body tell what is the problem and how can i add a dll as reference.
thanks for your help
M.MohanVamsi
|
|
|
|
|
I believe you just add it to your bin folder and then refer to it from there.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|