|
hii friends, my line of code is
dv.RowFilter = "Date=" + Convert.ToDateTime(reportdate);
Date is the name of a column in my table and is of type Datetime.
reportdate is a variable of type string.
I am getting this SyntaxErrorException.
Syntax error: Missing operand after '12' operator.
plz help me to solve this error.
Thanks.
|
|
|
|
|
try this
dv.RowFilter = String.Format(CultureInfo.InvariantCulture.DateTimeFormat,
"Date = #{0}#", Convert.ToDateTime(reportdate));
It should work.
|
|
|
|
|
now it is saying like this
Cannot perform '=' operation on System.String and System.DateTime.
|
|
|
|
|
your Date column is of which time? string or Datetime. Both should be same.
And also one more in which format the date is in dataview. Both should be same.Accordingly convert the datetime object.
|
|
|
|
|
the Date column is of datetime type.
reportdate is of type string and contains "01/01/10"
in the dataview the format of Date is as follows
#01/01/2010 00:00:00#
|
|
|
|
|
As I suggested put the use the dataetime objects in same format at both end.
Have a look to this link
|
|
|
|
|
Enclose the date in single quotes
dv.RowFilter = string.Format("Date='{0}'", Convert.ToDateTime(reportdate));
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
now am getting
Error: String was not recognized as a valid DateTime.
dv.RowFilter = string.Format("Date='{0}'", Convert.ToDateTime(reportdate));
the reportdate contains "01/01/10"
and in the dataview the format of date is:
Date='1/1/2010 12:00:00 AM'
is this error because of the date formats? if so how to make them compatible.
|
|
|
|
|
DateTime dt;
if(DateTime.TryParse(reportDate, out dt))
{
dv.RowFilter = string.Format("Date='{0}'", dt);
}
or the overload
if(DateTime.TryParse(reportDate, IFormatProvider, Style, out dt))
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
If you don't care about the time portion use this
<br />
dv.RowFilter = string.Format( "Date='{0}'", reportdate.ToString("dd/MM/yyyy");<br />
|
|
|
|
|
still i could not solve it.
i am getting the following error when i am trying this..
dv.RowFilter = string.Format("Date='{0}'", reportdate.ToString("dd/MM/yyyy"));
The best overloaded method match for 'string.ToString(System.IFormatProvider)' has some invalid arguments
|
|
|
|
|
Sorry, I didn't realize that you were using the string value. To use the string, use
<br />
dv.RowFilter = string.Format("Date='{0}'", Convert.ToDateTime(reportdate).ToString("dd/MM/yyyy"));<br />
|
|
|
|
|
hi,
my html look good in IE but it look odd in firefox but i can not understand the reason.i work with checklistbox.so i am giving my html snippet below. please anyone check it and tell me why it is looking bad or cluttered in Firefox.how to make it compatible for all the browser.
html
<TABLE id="Table4" cellSpacing="1" cellPadding="1" width="58%" bgColor="#d8e4f8" border="0">
<TR><TD vAlign="top" noWrap width="10%"><span id="Label2" style="font-weight:bold;">Date</span>
<input name="txtDate" type="text" readonly="readonly" id="txtDate" style="border-style:Groove;" /></TD>
<TD vAlign="middle" noWrap width="7%"> <span id="Label3" style="font-weight:bold;">Country</span></TD>
<TD vAlign="top" width="36%"><table id="chkCountry" border="0" style="font-weight:bold;width:100%;">
<tr><td><input id="chkCountry_0" type="checkbox" name="chkCountry " /><label
for="chkCountry_0">UK</label></td><td><input id="chkCountry_1" type="checkbox" name="chkCountry:1" /><label
for="chkCountry_1">USA</label></td><td><input id="chkCountry_2" type="checkbox" name="chkCountry:2" /><label
for="chkCountry_2">Germany</label></td><td><input id="chkCountry_3" type="checkbox" name="chkCountry:3" /><label
for="chkCountry_3">France</label></td><td><input id="chkCountry_4" type="checkbox" name="chkCountry:4" /><label
for="chkCountry_4">Italy</label></td><td><input id="chkCountry_5" type="checkbox" name="chkCountry:5" /><label
for="chkCountry_5">Canada</label></td><td><input id="chkCountry_6" type="checkbox" name="chkCountry:6" /><label
for="chkCountry_6">Netherlands</label></td>
</tr></table></TD><TD vAlign="top" width="5%"><button language="javascript" onclick="setTimeout('javascript:IsBusy(1);',50);
__doPostBack('btnGo','')" id="btnGo" type="button" value="GO"></button></TD>
</TR><TR><TD vAlign="top" noWrap width="10%"></TD><TD vAlign="middle" noWrap width="7%"></TD><TD vAlign="top" align="right" width="36%">
<a id="HyperLink1" href="EODMain.aspx">Main Menu</a></TD><TD vAlign="top" width="5%"></TD></TR></TABLE>
tbhattacharjee
|
|
|
|
|
There is a tool firebug install it in your browser, and with help of that you will be able to know what is the exact problem..
|
|
|
|
|
Tridip Bhattacharjee wrote: .how to make it compatible for all the browser.
You need to work on CSS. Need to create different css class insted of giving direct value in aspx page.
|
|
|
|
|
Use This code Solve ur prob..
<table cellspacing="1" cellpadding="1" bgcolor="#d8e4f8"
border="0">
<tr>
<td valign="top" nowrap >
<span id="Label2" style="font-weight: bold;">Date</span>
<input name="txtDate" type="text" readonly="readonly" id="txtDate" style="border-style: Groove;" /></td>
<td valign="middle" nowrap >
<span id="Label3" style="font-weight: bold;">Country</span></td>
<td valign="top">
<table id="chkCountry" border="0" style="font-weight: bold; ">
<tr>
<td>
<input id="chkCountry_0" type="checkbox" name="chkCountry:0" /><label for="chkCountry_0">UK</label></td>
<td>
<input id="chkCountry_1" type="checkbox" name="chkCountry:1" /><label for="chkCountry_1">USA</label></td>
<td>
<input id="chkCountry_2" type="checkbox" name="chkCountry:2" /><label for="chkCountry_2">Germany</label></td>
<td>
<input id="chkCountry_3" type="checkbox" name="chkCountry:3" /><label for="chkCountry_3">France</label></td>
<td>
<input id="chkCountry_4" type="checkbox" name="chkCountry:4" /><label for="chkCountry_4">Italy</label></td>
<td>
<input id="chkCountry_5" type="checkbox" name="chkCountry:5" /><label for="chkCountry_5">Canada</label></td>
<td>
<input id="chkCountry_6" type="checkbox" name="chkCountry:6" /><label for="chkCountry_6">Netherlands</label></td>
</tr>
</table>
</td>
<td valign="top" >
<button language="javascript" onclick="setTimeout('javascript:IsBusy(1);',50);
__doPostBack('btnGo','')" id="btnGo" type="button" value="GO">
</button>
</td>
</tr>
<tr>
<td valign="top">
</td>
<td valign="middle" >
</td>
<td valign="top" align="right" >
<a id="HyperLink1" href="EODMain.aspx">Main Menu</a></td>
<td valign="top" >
</td>
</tr>
</table>
Hope this will help!
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
thanks it works but u did not explain what u add or rectify. plzzz mention.
thanks a lot.
tbhattacharjee
|
|
|
|
|
I have a datalist and now i want to give custome paging to that datalist using multiple active result set. I mean i want to show paging as
first,previous,1 2 3. . . next, last.
In this I want to get only 3 pages at a time. and once i got the page, I want to put it in caching and again if user click on that page number then i dont want
to get the data from cache instead of hitting the database.pls its urgent.pls help me.
Happy
|
|
|
|
|
hi , iam using asp.net with c#
iam displaying images using Handler.ashx but when there is no image present in a database i want to display nopic.jpg picture
can you correct my code which helps me
using System;
using System.Web;
using System.IO;
using System.Data;
using System.Data.SqlClient;
public class left1old : IHttpHandler {
public void ProcessRequest (HttpContext context)
{
int branchid = 0;
if (context.Session["branchid"] != null)
branchid = Convert.ToInt32(context.Session["branchid"]);
else
throw new ArgumentException("No parameter specified");
context.Response.ContentType = "image/jpeg";
Stream strm = ShowImage(branchid);
byte[] buffer = new byte[4096];
int byteSeq = strm.Read(buffer, 0, 4096);
while (byteSeq > 0)
{
context.Response.OutputStream.Write(buffer, 0, byteSeq);
byteSeq = strm.Read(buffer, 0, 4096);
}
}
public Stream ShowImage(int branchid)
{
SqlConnection con = new SqlConnection(" Data Source=.; Initial Catalog=SafaView;User ID=sa;Password=nsg_ss_0103;");
string sql = "SELECT imgleft1old FROM tblImages WHERE BranchId = @branchid";
SqlCommand cmd = new SqlCommand(sql, con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@BranchId", branchid);
con.Open();
object img = cmd.ExecuteScalar();
try
{
return new MemoryStream((byte[])img);
}
catch
{
return System.IO.Stream("~/images/NoPic.jpg");
}
finally
{
con.Close();
}
}
public bool IsReusable {
get {
return false;
}
}
}
in page load
=============
protected void Page_Load(object sender, EventArgs e)
{int i=0;
i= Convert.ToInt32(Session["branchid"]);
if (IsPostBack == false)
{
Image1.ImageUrl = "left1.ashx?BranchId=" + i;
Image2.ImageUrl = "left1old.ashx?BranchId=" + i;
}
can you correct my code which helps me
|
|
|
|
|
Why tyou are using try catch, it is performance overhead, its better you return the nopic image from db itself, put it in some common table, if there is noimage for that record return nopic image, also you can read as you are doing, just check if there is nothing in image read it from localdrive and send it in the same format.
try to debug the code you'll get to know the exact problem
|
|
|
|
|
What u can do is keep a blank image in ur websites image folder and just check
MemoryStream strm = new MemoryStream((byte[])img);
if (strm.Length <= 0)
{
//Then load the blank image
}
Tej Aj,
http://opexsolution.com/forum/[^]
|
|
|
|
|
I can see a couple of issues with the code:
developerit wrote: return System.IO.Stream("~/images/NoPic.jpg");
Should this be:
return new System.IO.Stream(Server.MapPath("~/images/NoPic.jpg"));
It would help if you could tell us what the error is that you're seeing...
|
|
|
|
|
Hi,
I want to redirect my webpage to another form which has a loading progress bar and want to pause there for few sec and then redirect to other page...
How to implemnt this in asp.net...
Pls help
Thanks,
|
|
|
|
|
seemadas wrote: I want to redirect my webpage to another form which has a loading progress bar and want to pause there for few sec
Pause for what ? For showing the progress bar or after pause you want to show the progress bar ?
|
|
|
|
|
Pause for showing the page which has Lpading bar....
|
|
|
|