|
private static bool
F
(
object o
,
System.Type t
)
{
if ( o == null )
{
throw ( new System.ArgumentNullException() ) ;
}
return ( t.IsAssignableFrom ( o.GetType() ) ) ;
}
And may I humbly suggest my TypeTransmogrifier[^] ?
|
|
|
|
|
protected void bn_delete_Click(object sender, EventArgs e)
{
bn_del.Attributes("onclick") = "return confirm('Are you sure you wish to delete these records?');";
GridViewRow row;
foreach (row in GridView1.Rows) {
CheckBox idcb = row.FindControl("CheckBox1");
TextBox id = row.FindControl("id");
if (idcb.Checked) {
DataAccessLayer dal = new DataAccessLayer();
dal.Connect();
dal.deleteDB("DELETE FROM StaffID Where StaffIDID = '" + id.Text + "'");
dal.Close();
getStaff();
}
error message: type and identifier are both required in a foreach
statement
|
|
|
|
|
twistz wrote: foreach (row in GridView1.Rows)
I think you need to do
foreach (GridViewRow row in GridView1.Rows)
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 )
|
|
|
|
|
it states "the name "bn_del" does not exist in the current context",
"a local variable named "row" cannot be declared in this scope because it would give a different meaning to "row", which is already used in a "parent or current" scope to denote something else"
|
|
|
|
|
twistz wrote: the name "bn_del" does not exist in the current context",
Well, that's a whole different problem. What makes you think it should exist ?
twistz wrote: "a local variable named "row" cannot be declared in this scope because it would give a different meaning to "row", which is already used in a "parent or current" scope to denote something else"
That means you kept the old line in that defined that variable. You need to delete it. The error means what it says, you are defining it twice.
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 )
|
|
|
|
|
twistz wrote: foreach (row in GridView1.Rows) {
CheckBox idcb = row.FindControl("CheckBox1");
TextBox id = row.FindControl("id");
if (idcb.Checked) {
DataAccessLayer dal = new DataAccessLayer();
dal.Connect();
dal.deleteDB("DELETE FROM StaffID Where StaffIDID = '" + id.Text + "'");
dal.Close();
getStaff();
}
Try it :
foreach (var row in GridView1.Rows)
{
CheckBox idcb = row.FindControl("CheckBox1");
TextBox id = row.FindControl("id");
if (idcb.Checked)
{
DataAccessLayer dal = new DataAccessLayer();
dal.Connect();
dal.deleteDB("DELETE FROM StaffID Where StaffIDID = '" + id.Text + "'");
dal.Close();
getStaff();
}
}
Freshman
|
|
|
|
|
That's var abuse.
|
|
|
|
|
Whatever happened to the 'use strongly typed variable' rule? May as well define eveything as an object
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Ashfield wrote: Whatever happened to the 'use strongly typed variable' rule? May as well define eveything as an object
The variable is actually stronly typed, as the compiler can determine what type it has to be.
However, the code is not well written, as it's not obvious what the type of the variable will be. You can't read directly what the type is, you have to know what type the enumerator of the Rows collection returns. As there is two layers of indirection to follow, the code gets less readable. Also, the code gets more prone to accidental changes, as the declaration depends on other declarations.
If the intention was that the variable should get whatever type the enumerator returns it would be ok, but when the motivation is only laziness, it's not a coding style that can be recommended.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I has a C++ DLL, it has follow code:
typedef struct _SC_CONTEXT{
long hPort;
long dwCardType;
// BYTE params[24];
} SC_CONTEXT;
extern int __stdcall TestFunc(SC_CONTEXT* p)
{
char buf[256];
sprintf(buf, "hPort is : %d, dwCardType is : %d.", p.hPort, p.dwCardType);
// sprintf(buf, "hPort is : %d, dwCardType is : %d, params[0] is : %d.", p->hPort, p->dwCardType, p->params[0]);
MessageBoxA(NULL, buf, "caption1", MB_OK);
return 0;
}
I wrote C# code like :
[StructLayout(LayoutKind.Sequential)]
public struct _SC_CONTEXT
{
public long hPort;
public long dwCardType;
}
namespace MyName
{
class MyClass
{
[DllImport("testDll.dll")]
public static extern int TestFunc(ref _SC_CONTEXT11 a);
}
static void Main(string[] args)
{
unsafe
{
_SC_CONTEXT a;// = new _SC_CONTEXT();
a.hPort = 67;
a.dwCardType = 66;
// a.paras[0] = 255;
TestFunc(ref a);
}
......
}
}
the question is, function TestFunc can not get _SC_CONTEXT::dwCardType's value. In the messagebox, content always is "hPort is : 67, dwCardType is : 0.". I want to know why, and how to correct this bug. As you see, I comment an array member of the struct, if not comment it, how to use struct with array member.
|
|
|
|
|
I've spotted at least one bug immediately: .NET long is 64bit, but in C++ it's 32bit! So you should declare your struct with int instead:
samfromcn wrote: public struct _SC_CONTEXT
{
public long hPort;
public long dwCardType;
}
public struct _SC_CONTEXT
{
public int hPort;
public int dwCardType;
}
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Thank you very much. All questions are resolved.
|
|
|
|
|
I have a quick question about Attributes
When we use the Description attribute we normaly do it like this
[Description("Class that contains information about an user")]
public class user
{
}
But how come we can construct the type like Description("") and DescriptionAttribute("") ???
i mean, i can't seem to find the class called Description, when i look with the object browser, but the DescriptionAttribute is there.
I have been looking on MSDN, but nothing seems to popup about this.
Anyone have a answer
|
|
|
|
|
|
aha, i see, it seems that the Compiler looks this information up...
Quote from (Spacix One) link: The compiler first searches the attribute in System.Attribute derived classes...
Hmmm that information i could not find on the MSDN... or im not looking the right places...
Thanks Spacix One
|
|
|
|
|
|
yeah i know it can be hard, and i was by that site, but, nothing seemed to popup in my face about this...
but now i know, and thats whats counts.
|
|
|
|
|
DEAR MEMBERS,
CAN ANYBODY TELL ME HOW TO READ A WAV FILE FROM A XML DATA UISNG C#
Muneer
|
|
|
|
|
|
|
We have a program that we are using to 'print' and 'print preview' an html document that is being displayed within a C# program. We open a new webbrowser adding info using html statements and then add the contents of the original webbrowser to our new webbrowser. When we call wbMailBody1.Print(); or wbMailBody1.ShowPrintPreviewDialog(); we get an empty page. If we add the line
MessageBox.Show("");
immediately before calling wbMailBody1.Print(); or wbMailBody1.ShowPrintPreviewDialog(); it will work perfectly
the following code displays an empty page. if you check wbMailBody1.DocumentText.Length it will be 14 even if it should be the length of say 4 or 5 pages in length. If you look at wbMailBody1.DocumentText it will contain
the GetHTML() routine uses stringBuilder to create a string using sb.Append statements.
private void PrintMessagePreview1()
{
GetHeading();
if (viewMode == Dice.BodyViewMode.HTML)
{
wbMailBody1.DocumentText = GetHTML();
wbMailBody1.ShowPrintPreviewDialog();
}
else
{
printPreviewDialog1.ShowDialog();
}
}
If you make the following change to the code (MessageBox.Show statement) then all works just the way it should.
private void PrintMessagePreview1()
{
GetHeading();
if (viewMode == Dice.BodyViewMode.HTML)
{
wbMailBody1.DocumentText = GetHTML();
MessageBox.Show("");
wbMailBody1.ShowPrintPreviewDialog();
}
else
{
printPreviewDialog1.ShowDialog();
}
}
|
|
|
|
|
this.WebBrowser1.Document.InvokeScript("window.print");
-Spacix
All your skynet questions[ ^] belong to solved
I dislike the black-and-white voting system on questions/answers.
|
|
|
|
|
So I've got a client server application going (again) and I've run into a little problem.
So far the server side sits idly waiting for a connection, eventualy it will receive a connection from the client. After a period of time T the server will close the connection with the client if there is no activity (incase for some reason the client didn't disconnect as it should).
After closing the connection it waits again for a new connection. But, if the client that was previously connected tries to send data, then the server side picks this up as an incomming connection and trys to accept it, where I then get the exception becuase that line was already closed.
So what am i to do?
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
SK Genius wrote: After a period of time T the server will close the connection
How?
SK Genius wrote: After closing the connection it waits again for a new connection
How?
SK Genius wrote: So what am i to do?
Post useful information if you expect someone to be able to help you.
led mike
|
|
|
|
|
led mike wrote: After a period of time T the server will close the connection
How?
Calling .Close on the stream and .Stop() on the TcpListener .
led mike wrote: After closing the connection it waits again for a new connection
How?
Starting the TcpListener and calling BeginAcceptSocket
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|