|
I am binding a generic list of products List<products> to an ASP DataGrid and was wondering what the best way to convert the Product object integer values of 0 to an empty string when binding to the grid. See, the Product object contains integer properties and when reading from the database if the value read is DBNull I assign a value of 0 to the property. Now, when displaying the List<products> using databinding I want the 0 to show as empty strings in their columns. What do you recommend?
Thanks,
Steve
|
|
|
|
|
I would recommend a string property you bind to, that returns an empty string if it's 0. Or use int? and then use ?? to return an empty string, perhaps ?
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 )
|
|
|
|
|
Using a second property for binding sounds like the way to go.
Thanks for your help!!!!!!!!!
Steve
|
|
|
|
|
string val = string.Empty;
if (yourInteger != 0)
val = yourInteger.ToString();
Maybe I don't understand the question...
|
|
|
|
|
He wants to write binding statements in his aspx. He COULD do this, but it's messy
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 am trying to print to a receipt printer during our payment process.
The printer is not the default printer and I can't change that.
The problem is that from the browser you don't have permission to programatically get
a list of printers and select which one you want. So, currently we pop up the Print dialog
then select the desired printer and then click ok. This is two steps too many.
How can you get around this limitation and automate the printing of the receipt?
modified on Friday, June 6, 2008 11:29 AM
|
|
|
|
|
No, you cannot. As you said, in javascript, you can kick off the printing process, but you can't interact with it.
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 )
|
|
|
|
|
So, I guess we could create a client side windows web service which accepts the html and then have the web page post to it and then it could do the printing.
|
|
|
|
|
Well, a client side app that calls a web service, yes, that would work. Or an ActiveX control perhaps.
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 )
|
|
|
|
|
Yes, I didn't what to do an ActiveX control but either way it is a client side solution.
thanks for your input.
|
|
|
|
|
|
Hi all
I am using ASP.NET 3.0 and I have a list box in content page. I am using Master Page architecture. I am binding data from the database into the listbox. but it gives me error of "object reference not set to an instance of an object". This is what I am doing..
((ListBox)(this.FindControl("ctl00_ContentPlaceHolder1_lMondayFD1"))).DataSource = ds.Tables[0].DefaultView;
Please guys any one can help me
|
|
|
|
|
Are you able to find other controls at the same place ?
OR can you try like below :
Note: Be sure if your Listbox control defined in Content Place holder
ContentPlaceHolder mpContentPlaceHolder;
ListBox lb;
mpContentPlaceHolder = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
if(mpContentPlaceHolder != null)
{
lb=(ListBox ) mpContentPlaceHolder.FindControl("yourListboxid");
if(lb!= null)
{
lb.DataSource = ds.Tables[0].DefaultView;
}
}
OR In case List box placed on Master page then use try like this:
ListBox lb = (ListBox ) Master.FindControl("yourListboxid");
if(lb!= null)
{
lb.DataSource = ds.Tables[0].DefaultView;
}
Parwej Ahamad
R & D with IIS 5.0/6.0
modified on Friday, June 6, 2008 11:59 AM
|
|
|
|
|
Background:
We are using .NET 2.0 with the MS Ajax Extensions and the Ajax Toolkit. I'm using the Ajax ModalPopupExtender extender control to create modal popups on a page. I am using a custom datepicker control that uses javascript to pop up a calendar, and populates the textbox with the date selected.
Problem:
It seems that Javascript gets confused with the z-index of the popup. When used on a non-ajax popup panel, it works flawlessly. But, when it is placed on a modal popup panel, the javascript popup calendar is shown behind the modal form. Since the main form and the panel that is controlled by the modal popup are essentially the same form, the control cannot distinguish that its z-index should be set differently.
Failures:
I've tried moving the panel to the beginning of the page.
I've tried setting the z-index of the page to a high number
I've tried setting the z-index of the panel to 0 and 1
I've rechecked the code to verify it is not setting the z-index internally.
Any help on finding a solution to this problem would be greatly appreciated.
|
|
|
|
|
try to put an iframe under your custom calendar.
|
|
|
|
|
I'm looking for a way to make an applet communicate with the same aspx page it was loaded from and not a new one. Using the http protocol I'm able to connect the applet to the aspx, but it is a different one and I need to be the same since every aspx contains diferent information (data members).
|
|
|
|
|
Hi
Im trying to connect to sql server database through asp.net
The connection string works when connecting through access front end
But it doesnt work when connecting through .net, it says the credentials are not correct
any help would be great
thanks
We are not a Code Charity
|
|
|
|
|
If you are using a trusted connected then you have to remember that your ASP.NET application runs as a different user to you. So, when you connect using the wizard in Visual Studio you are using your credentials. When your applications runs then it is using the credentials of the ASP.NET process (normally NT AUTHORITY/NETWORK SERVICE). You have to give permission to that account in your SQL Server.
|
|
|
|
|
i ahve done the following:
connected through .net to another database in the same server
used the same crdentials
checked the username
tried a different username
i can connect through access but not .net
i cant connect but i dont know why...grr!
thanks for the reply
We are not a Code Charity
|
|
|
|
|
i have used an update panel on login page...its working fine on local but when i upload my page on net...its not working fine....the page is refreshed on every click of button....the code is..
<form id="f1" runat="server">
<atlas:ScriptManager ID="scriptmanager1" OnAsyncPostBackError="ScriptManager1_AsyncPostBackError" runat="server" ScriptPath="./Script" EnablePartialRendering="true">
</atlas:ScriptManager>
<div style="padding-right:30px;">
<atlas:UpdatePanel ID="upd1" UpdateMode="Conditional" RenderMode="Inline" runat="server">
<ContentTemplate>
<table width="50%" border="0" align="center" cellpadding="5" cellspacing="0" class="table">
<tr>
<td class="td" colspan="3" style="color: red">
<asp:Literal ID="ltrmsg" runat="server"></asp:Literal>
<asp:Label ID="lblmsg" runat="server"></asp:Label></td>
</tr>
<tr>
<td class="td"><strong>User ID </strong></td>
<td width="39%" class="td"><input name="user_id" type="text" class="form" runat="server" id="user_id" maxlength="20" /></td>
<td width="15%" rowspan="2" class="td"><input type="image" src="login.jpg" runat="server" name="Submit" value="Submit" id="Image1" onclick="return validForm();" onserverclick="Image1_ServerClick" tabindex="2" />
</td>
</tr>
<tr>
<td class="td"><strong> Password</strong></td>
<td class="td"><input name="pass" type="password" runat="server" class="form" id="pass" maxlength="20" tabindex="1"></td>
</tr>
</table>
</ContentTemplate>
</atlas:UpdatePanel>
</div>
</form>
but when user enter wrong user-id or password its not showing the msg in literal ...and the page is refreshed on every click please help me
|
|
|
|
|
Hi!
I'm newbie in ASP.NET world, but I read a good book about it.
My question is:
I have a web page with some controls, like text boxes, drop down lists and so on.
I'd like when an user change any data in any control, and then he/she try to close the browswer or try to leave the web page without save the data, it appear a message box warning that he/she will lose the changes.
Do you have any idea?
Thank you in advance.
--
[Adrián Córdoba]
|
|
|
|
|
Check this out:
http://www.eggheadcafe.com/articles/20010406.asp[^]
Tip: When you type into the CodeProject forum textbox and click back button, this warning comes. :)
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
All the world's a stage,
And all the men and women merely players.
They have their exits and their entrances;
And one man in his time plays many parts... --William Shakespeare
|
|
|
|
|
I am developing one web application using asp.net(vb.net), in this application, I have to display excel,word,powerpoint and pdf files in my browser but restrict the user to save that file and also disable cut,copy,paste,mouse right click and print options.
Please help me out ASAP from this problem.
Thanks
|
|
|
|
|
I believe these options are configurable whilst writing a PDF file but I don't think Office documents give those flexibilities/facilities.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
All the world's a stage,
And all the men and women merely players.
They have their exits and their entrances;
And one man in his time plays many parts... --William Shakespeare
|
|
|
|
|
I have a single webserver using win 2k8 and IIS 7 that is not on a web farm. For one particular page I keep getting one of these 2 errors when any event is executed on the page
Most of the time it is the viewstate error.
This error only happens in Internet Explorer 6 and 7.
I have used firefox and safari and everything works just fine it only happens in IE.
I have a chack box list and a couple of drop down lists on my page as well as a gridview etc.
I tried changing the machine key to no avail so i changed ot back to auto generate
I had read an article where you coudl store viewstate as a session but was not sure how to do that in VB.net
Any ideas how I can correct this?
Thanks
Here are the errors
Viewstate verification failed. Reason: The viewstate supplied failed integrity check.
Forms authentication failed for the request. Reason: The ticket supplied has expired.
|
|
|
|