|
The problem is your use of MultiSimple in the Listbox . The selected index is always the first one selected so if 1 is selected it always sets label1 visible and label2 not visible. Change the selection mode to One and you will see the difference. You will need to check all the selected items rather than just the index to be able to switch all labels correctly.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
HI Denis
try this,
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
listBox1.Items.Add("item 1");
listBox1.Items.Add("item 2");
listBox1.Items.Add("item 3");
listBox1.SelectedIndexChanged += new EventHandler(listBox1_SelectedIndexChanged);
this.listBox1_SelectedIndexChanged(this, new EventArgs());
}
public void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
label1.Visible = (listBox1.SelectedItems.Contains("item 1"));
label2.Visible = (listBox1.SelectedItems.Contains("item 2"));
label3.Visible = (listBox1.SelectedItems.Contains("item 3"));
}
Best regard,
Nilesh Raval
|
|
|
|
|
Thank you Nilesh and also Alan and Richard.
Nilesh, you pointed me in the right direction! Thanks for the explicit code. -.SelectedItems.Contains is exactly what did the job.
|
|
|
|
|
Always welcome
|
|
|
|
|
Respected Sir,
I am new in web base application using c# & back end sql 2005 , I am create report file in crystal 10
please help me.
strFileNm = 'RpItemLst";
strFileNmWithPath = Server.MapPath(strFileNm + ".rpt");
RepDoc.Load(strFileNmWithPath);
===========below error============
Server Error in '/FactoryProduction' Application.
--------------------------------------------------------------------------------
Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack.
Source Error:
Line 157: //RepDoc.Load(strFileNmWithPath, OpenReportMethod.OpenReportByTempCopy);
Line 158: // RepDoc.Load("d:/sanadi/factoryproduction/RpItemLst.rpt");
Line 159: RepDoc.Load(strFileNmWithPath.ToString());
Line 160: CrystalReportViewer1.ReportSource = RepDoc;
Line 161: CrystalReportViewer1.DataBind();
Source File: d:\sanadi\FactoryProduction\RepItem.aspx.cs Line: 159
Stack Trace:
[COMException (0x80041811): Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack.]
CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) +144
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +549
[CrystalReportsException: Load report failed.]
CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +650
CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) +1823
CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) +186
RepItem.BtnPrint_Click(Object sender, EventArgs e) in d:\sanadi\FactoryProduction\RepItem.aspx.cs:159
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
|
|
|
|
|
Does the first answer to this StackOverflow question[^] help?
- Right click the Rpt file.
- Choose the properties
- Changed
- Build Action as "Content"
- Copy to Output Directory as "Do not Copy"
- Put Empty for Custom Tool and Custom Tool Namespace
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
how to load values into combobox in c#
|
|
|
|
|
See the Remarks section in the documentation[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Well, it really depends on what platform you are using, but typically you have have one of two ways. The first way is to add an item at a time, in the same way you'd add to a generic list. The second way is to use databinding.
|
|
|
|
|
How restrict ideal time out because i have written 1 web application that should not log out if the llogged in user go for ideal time, until unless logged in user logout it should not ask for re login .
|
|
|
|
|
Use cookies on the client to record the log in - you can get them to never expire if you need to.
There is plenty of info on this: Google[^]
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
cookies not enabled so i cant use cookies
|
|
|
|
|
Have a read of this
Overriding the default session time in asp.net and IIS[^]
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Setting the session expiry to a very large value is a bad idea. It means that your server ends up storing live session data for every user that has visited the site during the session expiry time.
The normal way to do this (auto login after a long idle time) is to use a cookie to skip authentication on coming back to the site.
Alternatively, you can use keep-alive AJAX requests to maintain a session while the user is actually still looking at the site (or at least has it open in a browser).
|
|
|
|
|
Hi BobJanova,
Thank you so much for your detail explanation,
|
|
|
|
|
My fancy new WD MyNet 900 Wireless Router periodically requires a reboot to establish an Internet connection with the rest of my devices. I know that Windows can detect when the network connection is lost, but I'd like to do so myself in C#, and trigger a reboot of the router via a hardwired network connection to an IP-enabled ac outlet that provides power to the router. Yeah, it's a kluge, but I like the router otherwise. It just likes to go to sleep sometimes.
I'm currently preparing an Iris-based home automation system, and the last thing I need is for it to be unable to call me when it needs to, just because this silly router has lost its way. Trouble is, I have no idea what to search for in the .Net documentation. Can anyone suggest a class that can monitor and fire an event when the network connection is lost on a wireless interface?
My thinking is, I can run a service on my main computer that monitors the wireless network connection. When it detects that the connection has failed, it cycles the power outlet for the router using a hardwired Ethernet network and waits for a minute to see if the wireless network is re-established. If not, it can try again as often as needed to fix the problem; I'd set some maximum number of retries before assuming that the ISP is sucking again and giving up. If I was willing to pay for it, I do have a couple of cellular modems I could then use to have it call the ISP over and over again until someone fixes the service, but that would cost a bit more than I'm willing to pay to Sprint. Still, it could be fun. But I digress...
Where should I be finding a function to detect a lost wireless connection? MSDN hasn't been much help tonight, but Google found a useful GetIsNetworkAvailable function in the System.Net.NetworkInformation namespace. Unfortunately, this call will return true even if the upstream Internet connection has been lost. The article stops just short of providing any useful information for handling that situation.
Will Rogers never met me.
|
|
|
|
|
|
Cool! That isn't exactly what I'm looking for, but I think it contains enough information for me to customize it. Thanks a bunch!
Will Rogers never met me.
|
|
|
|
|
What I did to manage things was to use the web-based command/status interface of the modem/router and some HTML parsing. For example, I get hourly reports of the ADSL line status (speed/attenuation/margin, up and down) this way, and I can reboot it by going to the appropriate URL (after logging in, of course)
27/11/12 15.00.34,12864 kbps,42.0 db,6.20 db,1020 kbps,20.5 db,7.0 db
27/11/12 16.00.34,12793 kbps,42.5 db,6.45 db,1020 kbps,20.5 db,7.0 db
I also set up a syslog daemon and got the modem/router to log everything. So when the telco tech called this moring to look at my line problems, I could show him logs like this:
2012-11-27 12:45:40 User.Emerg 172.19.243.1 [Internet disconnected]
2012-11-27 12:47:04 User.Emerg 172.19.243.1 [Internet connected] IP address: 101.174.189.211,
2012-11-27 12:59:55 User.Emerg 172.19.243.1 [Internet disconnected]
2012-11-27 13:01:16 User.Emerg 172.19.243.1 [Internet connected] IP address: 203.51.49.191,
2012-11-27 15:47:16 User.Emerg 172.19.243.1 [DHCP IP: (172.19.243.125)] to MAC address 00:1A:4B:62:40:3F,
Helps no end convincing them that there actually is a problem.
If you want any more along these lines, email me.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Thanks, Peter!
Will Rogers never met me.
|
|
|
|
|
In the code snippet below when i try to check if column row is not equal to null is throw an error: System.NullReferenceException: Object reference not set to an instance of an object
SPList srcList = web.List["My List Name"];
foreach(SPListItem item in srcList.Items)
{
if((DateTime)item["Start Date"] != null)
{
//do something
}
}
|
|
|
|
|
zeqir85 wrote: if((DateTime)item["Start Date"] != null)
You do the typecast before you check if it's null. So it should be like this:
if((DateTime)item["Start Date"] != null)
By the way: as it's SharePoint you could use the SharePoint Board.
------------------------------
Author of Primary ROleplaying SysTem
How do I take my coffee? Black as midnight on a moonless night.
War doesn't determine who's right. War determines who's left.
|
|
|
|
|
Thank you very much. It works now.
|
|
|
|
|
Considering
(double)item["Start Date"]
would likely crash, perhaps
item["Start Date"] is DateTime
is a better alternative?
But then, I don't know anything about the sharepoint list object. Just assuming that it matches all other Microsoft enumerable collections.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: perhaps
item["Start Date"] is DateTime
is a better alternative?
Yes. Definitely!
------------------------------
Author of Primary ROleplaying SysTem
How do I take my coffee? Black as midnight on a moonless night.
War doesn't determine who's right. War determines who's left.
|
|
|
|