|
Every method that does something like "return someObject == null || someObject.SomeProperty == someValue;" can cause that exception (but only if it's called in a useless loop).
And it's fixed in .NET 2.0 SP1.
|
|
|
|
|
I have a ListBox set as Multiselect. I am populating the table thruough asp.net code. But I am using another dataset to get the items that should be selected. The only item that ends up selected is the last item in the dataset, and I know in several cases there are at least two items that should be selected. The code I am using for setting the selected items is:
DataSet ds1 = SqlHelper.ExecuteDataset(ConnStr, "StoredProd", Parm);
lbRequestTime.SelectionMode = ListSelectionMode.Multiple;
foreach (DataRow row in ds1.Tables[0].Rows)
{
lbRequestTime.SelectedValue = row["PerfTimeId"].ToString();
}
Any help on how to get the Mulitple selected items selected would be great.
Thanks, Doug
modified on Tuesday, March 25, 2008 9:33 AM
|
|
|
|
|
Hi,
you can use the following code
<br />
ListItem li;<br />
foreach (DataRow row in ds1.Tables[0].Rows)<br />
{<br />
li = lbRequestTime.Items.FindByValue(row["PerfTimeId"].ToString());<br />
if (li != null)<br />
li.Selected = true;<br />
}<br />
Do let me know if you need more info.
Cheers...
|
|
|
|
|
Hi,
I am using two sitemaps.I wrote code like this
web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="Default.aspx" title="" description="Home">
<siteMapNode url="Default.aspx" title="Computer" description="Computer" >
<siteMapNode url="Default.aspx" title="Laptop" description="Laptop" />
<siteMapNode url="Default.aspx" title="Desktop" description="Desktop" />
</siteMapNode>
</siteMapNode>
</siteMap>
web1.sitemap
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="" title="User" description="User">
<siteMapNode url="" title="Forgot Password" description="Forgot Password" />
<siteMapNode url="" title="Change Password" description="Change Password" />
<siteMapNode url="" title="Login" description="Login" />
</siteMapNode>
</siteMap>
Web.config
<siteMap enabled="true">
<providers>
<add name="Example" type="System.Web.XmlSiteMapProvider" sitemapfile="~/Web.sitemap"/>
<add name="Example1" type="System.Web.XmlsitemapProvider" sitemapfile="~/Web2.sitemap"/>
</providers>
</siteMap>
.aspx page
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" SiteMapProvider="Example" />
It showing following error
Server Error in '/MultipleSitemap' Application.
The attribute 'sitemapfile' is unexpected in the configuration of the 'Example' provider.
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.Configuration.ConfigurationErrorsException: The attribute 'sitemapfile' is unexpected in the configuration of the 'Example' provider.
Source Error:
[No relevant source lines]
Source File: c:\Documents and Settings\system3\Local Settings\Temp\Temporary ASP.NET Files\multiplesitemap\85793d13\552d1a9d\App_Web_dbjhdcj7.0.cs Line: 0
How to solve this?
anyone help me please.
|
|
|
|
|
This is case sensitive. Use siteMapFile instead of sitemapfile . Please remove the posts below as well.
|
|
|
|
|
|
Hi,
Has anyone worked with Client Application Services in Visual Studio 2008? Can someone please tell me where I can find a good tutorial on using Client Application Services concerning SQL 2005? I have a lot of tutorials on how to impliment it but there's nothing on how to impliment it using SQL Server.
Thank you!!
Illegal Operation
Making Computer Software Talk
|
|
|
|
|
Hi,
I am using two sitemaps.I wrote code like this
web.sitemap
<sitemap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<sitemapnode url="Default.aspx" title="" description="Home">
<sitemapnode url="Default.aspx" title="Computer" desscription="Computer">
<sitemapnode url="Default.aspx" title="Desktop" description="Desktop">
web1.sitemap
<sitemap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<sitemapnode url="" title="User" description="User">
<sitemapnode url="" title="Forgot Password" description="Forgot Password">
<sitemapnode url="" title="Change Password" description="Change Password">
<sitemapnode url="" title="Login" description="Login">
Web.config
<sitemap enabled="true">
<providers>
<add name="Example" type="System.Web.XmlSiteMapProvider" sitemapfile="~/Web.sitemap">
<add name="Example1" type="System.Web.XmlsitemapProvider" sitemapfile="~/Web2.sitemap">
.aspx page
<asp:sitemapdatasource id="SiteMapDataSource1" runat="server" sitemapprovider="Example">
It showing following error
Server Error in '/MultipleSitemap' Application.
The attribute 'sitemapfile' is unexpected in the configuration of the 'Example' provider.
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.Configuration.ConfigurationErrorsException: The attribute 'sitemapfile' is unexpected in the configuration of the 'Example' provider.
Source Error:
[No relevant source lines]
Source File: c:\Documents and Settings\system3\Local Settings\Temp\Temporary ASP.NET Files\multiplesitemap\85793d13\552d1a9d\App_Web_dbjhdcj7.0.cs Line: 0
How to solve this?
anyone help me please.
|
|
|
|
|
Hi,
I am using two sitemaps.I wrote code like this
web.sitemap
<sitemap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<sitemapnode url="Default.aspx" title="" description="Home">
<sitemapnode url="Default.aspx" title="Computer" desscription="Computer">
<sitemapnode url="Default.aspx" title="Desktop" description="Desktop">
web1.sitemap
<sitemap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<sitemapnode url="" title="User" description="User">
<sitemapnode url="" title="Forgot Password" description="Forgot Password">
<sitemapnode url="" title="Change Password" description="Change Password">
<sitemapnode url="" title="Login" description="Login">
Web.config
<sitemap enabled="true">
<providers>
<add name="Example" type="System.Web.XmlSiteMapProvider" sitemapfile="~/Web.sitemap">
<add name="Example1" type="System.Web.XmlsitemapProvider" sitemapfile="~/Web2.sitemap">
.aspx page
<asp:sitemapdatasource id="SiteMapDataSource1" runat="server" sitemapprovider="Example">
It showing following error
Server Error in '/MultipleSitemap' Application.
The attribute 'sitemapfile' is unexpected in the configuration of the 'Example' provider.
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.Configuration.ConfigurationErrorsException: The attribute 'sitemapfile' is unexpected in the configuration of the 'Example' provider.
Source Error:
[No relevant source lines]
Source File: c:\Documents and Settings\system3\Local Settings\Temp\Temporary ASP.NET Files\multiplesitemap\85793d13\552d1a9d\App_Web_dbjhdcj7.0.cs Line: 0
How to solve this?
anyone help me please.
|
|
|
|
|
Here is the deal:
I have got quite old application which was written in VB 6 using some ActiveX Controls. My task is to perform some automatic test using Quick Test Pro, which doesn’t recognize those ActiveX controls, but it doesn’t matter.
What I want to attain is to get control over an another application ActiveX control using its window’s (control’s) handle. http://rotanes.pl/Project1.exe <- here is really simple application (requires VB 6 runtime) with a data grid (microsoft Data Grid Control 6.0, MSDATAGRID.OCX) and one button, which changes data grid height. I want to be able to do the same from, for example, .net application. Just pass the handle (I can take it from any spy software) and perform the action.
What I discovered:
This ActiveX grid implements some COM interfaces, which are defined in the same dll (ocx) file, just use OLE/COM Viewer and everything is visible. So I’ve spent more then one week trying (using .net and C#) grab this interface knowing only controls hwnd.
My attempts (I used to be a .net developer so I wrote everything in C#):
-> Implement interface _cGrid (which is the interface I would like to cast a COM as) by myself:
[ComImport, Guid("60E9A471-E4DF-4687-B419-15A644E8AD57]
public interface _cGrid
{…}
Or use the one generated by tlbimp.exe.
-> import some extern procedures:
[DllImport("oleacc.dll", PreserveSig = false)]
[return: MarshalAs(UnmanagedType.Interface)]
public static extern object AccessibleObjectFromWindow(IntPtr hwnd, uint dwId, ref Guid riid);
(I tried this import in several different manners, for example with UnmanagedType.IUnknonw, UnmanagedType.IDispatch, adding “out IntPtr ppvd“as the last parameter and changing returned value to int…)
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);
-> Dozens of tries to make everything working (unsuccessfully ):
_cGrid result = (_cGrid )InteropClass.AccessibleObjectFromWindow(handle, 0, ref ITypeInfoGuid); <- throws en exception “Invalid Cast”
InteropClass.AccessibleObjectFromWindow(handle, 0, ref ITypeInfoGuid, out _cGridPtr); <- after every statement execution _cGridPtr has different value and it is different from Marshal.GetIUnknownForObject(obj) (I had reference to the control for my learning purposes, but I won’t have). It sends single WM_GETOBJECT message to the control wit 0xffffffff and 0x00000000 parameters (the second parameter referes to the second parameter of AccessibleObjectFromWindow procedure) which always returns different value (the subtraction of two sibling values equals 32, coincidence?)
Marshal.GetTypedObjectForIUnknown <- always throws “invalid cast exception” or something like this.
I would appreciate any (the simpler the better, prefereably c# by can be managed/unmanaged c++ or VB as well) example of code which works and can retrieve valid IUnknown pointer (or even cast pointer as interface) from ActiveX control knowing only its hwnd.
I found followiong links helpful:
[Some basis]
http://www.codeguru.com/csharp/csharp/cs_misc/com/article.php/c9065/
http://www.clarionmag.com/cmag/v1/v1n6callingole_part1.html
http://www.codeproject.com/KB/COM/COM_from_scratch_1.aspx
[I think the same problem]
http://www.vbforums.com/archive/index.php/t-158336.html
[Hopeful links]
http://www.thescripts.com/forum/thread233284.html
http://msdn2.microsoft.com/en-us/library/ms696137(VS.85).aspx
Especially -> Clients call this function to retrieve the address of an object's IAccessible, IDispatch, IEnumVARIANT, IUnknown, or other supported interface pointer.
I originally posted this message on http://www.codeguru.com/forum/showthread.php?p=1700068
Thanks in advance.
|
|
|
|
|
How to determine what process is running at the active TCP ports??
Som
|
|
|
|
|
Hi everyone
Is anybody can help me, I have a problem here , how to generate not repeated random integer values ?
Thanx in advance
Regard,
Edwin
|
|
|
|
|
|
I assume he means he wants the random numbers to not repeat. 4 2 3 1 5, not 4 2 1 4 5
Christian Graus - Microsoft MVP - C++
"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 need to write an article, this gets asked so often.
You create a list of numbers, which is the range of numbers you want to choose from ( such as 1-100 ).
You generate a random number between 0 and 99 ( for example ). You pull the number at that index out, and remove it from the list. Next time, you generate a number between 0 and 98, and do the same. And so on.
The other option is to write a custom sorting routine that returns a random number, but I've never tried that, I'm not sure if it wouldn't end up going for ever as the sort order keeps changing.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Christian Graus wrote: You create a list of numbers, which is the range of numbers you want to choose from ( such as 1-100 ). You generate a random number between 0 and 99 ( for example ). You pull the number at that index out, and remove it from the list. Next time, you generate a number between 0 and 98, and do the same. And so on.
Hey, Christian, your technique works very well if the sample size is small and many of those numbers will be used (for instance, you want 15 unique random numbers less than 25).
If the sample size is large ( 0 - 10 million ) and very few of them will be used, you are better off generating numbers within the range and checking if they have already been generated (you have to maintain a list for that). If not, you add the number to the list and use it.
Cheers,
Vikram.
Zeppelin's law: In any Soapbox discussion involving Stan Shannon, the probability of the term "leftist" or "Marxist" appearing approaches 1 monotonically.
Harris' addendum: I think you meant "monotonously".
Martin's second addendum: Jeffersonian... I think that should at least get a mention.
|
|
|
|
|
how many teachers are going to get their students to run this code on a sample size that large though
|
|
|
|
|
Yes, that's probably true, I can't imagine needing a small number of unique values between 1 and 10 million, tho. I guess it's possible, and what you say is a good point.
Christian Graus - Microsoft MVP - C++
"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 this problem that requires different areas (30x40, 10x40) of radio buttons.
How can I do this on the fly? I can't figure out how can I create the radio buttons and add them to the panel using a for loop? I want to name the radio buttons rb_1_1, rb_1_2 or rb11, rb12, etc.
I know I have to create the radio button objects -> RadioButton rb_1_1 = new RadioButton()
but how would I change the rb_1_1 when it loops again?
Thanks.
Desmond
|
|
|
|
|
|
Sorry Gareth, that's not want I wanted.
I know I can do it that way but what if I have 1000 radio buttons I want to create,
RadioButton rb_1_1 = new RadioButton();
RadioButton rb_1_2 = new RadioButton();
and so on
for 1000 times.
Is there a way to do it programmatically, so that I can just create a for loop and it creates the radio buttons for me?
And I need to do this in windows not ASP.net (I can do it in ASP.net).
Thanks.
Desmond
|
|
|
|
|
Desmond Lim,
Just do:
for (int i = 0; i < 1000; i++)
{
}
Why do you want to create 1000 radio buttons? Can you give a bit more info on what your trying to do because there might be a better way around it.
Regards,
Gareth.
|
|
|
|
|
I'm creating a software that allows the user to enter data for research purposes.
The slide/grid they use comes in different sizes, 20x30, 40x40, 100x30, etc. They want to be able to choose the size (by list box) and when a particular size is chosen, the grid of radio buttons corresponding to the size that they want will be created i.e. if they choose 20x30, 20 columns by 30 rows of radio buttons will be created.
The radio buttons will then be use to enter the data that corresponds to that part of the grid, that is to say, when the user clicks the Col 2 and Row 3 radio button, a window might pop up with the information needed for that part. Which means that each individual radio button has to be identifiable.
So back to my question how do you do a create radio button with different IDs because I know that when you do a
RadioButton rb01 = new RadioButton(); it creates the radio button object, I just don't know how to create radio buttons that have different IDs, i.e. rb01, rb02, rb03, etc. via using a loop. I know that if I do something like
for (int i = 0; i < 1000; i++)<br />
{<br />
RadioButton rbNew = new RadioButton();<br />
(move rbNew to a particular x y coordinate);<br />
rbNew.name = "rb01";<br />
}
This doesn't seem to work for I only get 1 radio button.
If you can think another way to do this, I'll really appreciate it.
Thanks.
Desmond
|
|
|
|
|
Desmond Lim,
rbNew.name = "rb" + i.ToString();
Regards,
Gareth.
|
|
|
|
|
hello every body
DO some one have any idea about how to prevent a specific file to be downloaded when i try to download something from the internet.
For example suppose that file name is: Somme.Cs
so when i try to download any kind of package and this package contain the current file name so the download should be stopped.
best regard
dghdfghdfghdfghdgh
|
|
|
|
|