|
Hi Sejal,
Can you please post your code here ,so one can provide the solution ?
Regards
|
|
|
|
|
for (int i = 0; MarkupList.Rows.Count; i++)
{
if (MarkupList.Rows[i].ItemArray.GetValue(4) == "No")
{
MarkupList.Rows[i].ItemArray.SetValue("ENG_NO", 4);
}
else if (MarkupList.Rows[i].ItemArray.GetValue(4) == "None")
{
MarkupList.Rows[i].ItemArray.SetValue("Eng_NONE", 4);
}
else if (MarkupList.Rows[i].ItemArray.GetValue(4) == "Yes")
{
MarkupList.Rows[i].ItemArray.SetValue("ENG_YES", 4);
}
}
May be this is not correct. But i wanted to know the method to update datatable field values.
sejal
|
|
|
|
|
How do i declare array inside a struct.Cause i got error, and it said should use new keyword to declare. For example:
public struct MY_TRUCT
{
public int Number;
public string Description;
public string ParaTypes[20];
}
|
|
|
|
|
may be like this
public struct MY_TRUCT
{
public int Number;
public string Description;
public string[] ParaTypes = new string[20];
}
rahul
|
|
|
|
|
No, that doesn't work. You can't initialize the members of a struct.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
You can't create an array in the declaration of a struct.
Do you have any reason to make it a struct? Otherwise you should make it a class. Implementing a struct correctly is more complicated than implementing a class correctly.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
As it was said, you cannot initialize struct member, neither can you use parameterless constructor,
but you can use a constructor with parameters and initialize you array there.
Something like this:
public struct MY_TRUCT
{
public int Number;
public string Description;
public string ParaTypes[];
public MY_TRUCT(string[] paraTypes) {
ParaTypes = paraTypes;
}
}
Regards,
Lev
modified on Tuesday, December 30, 2008 1:06 AM
|
|
|
|
|
With some corrections, that would work, but it still isn't a good implementation of a struct.
Consider this:
MY_TRUCT x = new MY_TRUCT(new string[] { "a", "b" } );
Console.WriteLine(x.ParaTypes[0]);
MY_TRUCT y = x;
y.ParaTypes[0] = "c";
Console.WriteLine(x.ParaTypes[0]);
Mutable structs can give you surprising results, structs containing mutable objects can give you even more surprising results...
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: With some corrections, that would work, but it still isn't a good implementation of a struct.
Nobody says it is
I just wanted to make a point that he can initialize a struct member with a constructor with parameters, if a non-default value is needed.
Regards,
Lev
|
|
|
|
|
public string ParaTypes[20]
i got error: array size can not be specified in a variable declaration?
|
|
|
|
|
Oops, of course you can't, the array has to be specified during the initialization
Fixed the post, sorry for that (didn't have a compiler at the moment )
Regards,
Lev
|
|
|
|
|
Hi all,
I have an XML as following. I'm trying to read it with the following code:
DataSet cars = new DataSet();
cars.ReadXml("http://localhost/cars/newcars.xml");
All the nodes are getting properly populated into the Dataset created EXCEPT the "description" node. I can't find a way to make ReadXML (or similar method) to get the content of the description node and skip the HTML tags. I would like just treat that portion as pure text, ignoring the html content.
My question would be: How can I read an XML file which some of the nodes have HTML tags inserted? How could I avoid that the program treats the HTML tags as XML nodes>
thanks,
Juan
<cars>
<car>
<color>red</color>
<model>ford</model>
<description>
<p xmlns="http://www.w3.org/1999/xhtml"><span class="textnorm" title="">Super</br>fast</br></span></p><h2 xmlns="http://www.w3.org/1999/xhtml"><span class="textnorm" title="">Reasons to buy</span></h2><p xmlns="http://www.w3.org/1999/xhtml">Just because</p>
</description>
</car>
</cars>
|
|
|
|
|
HTML content should be placed inside a CDATA section. So XML parsers will ignore it.
|
|
|
|
|
thanks! I'll work on that solution.
-- Juan
|
|
|
|
|
Hai all,
In my datagridview i have multple cells.i need values in all cell in each roe.
Suppose my dgridvw contains name and order as two fields.
my requirement is for each row i need value of cells separately
ie
i used a generic list
list<demo> myDemo=new list<demo>();
demo dm=new demo();//demo is class
for(i=0;i<tabCount;i++)
{
foreach(datagridviewrow row in dgv.rows)
{
dm.text=row.cells[0].value.tostring();
dm.order=row.cells[1].value.tostring();
}
myDemo.add(dm);
}
in first row i entered text=myText and order=1
in second row i entered text=urText and order=2
but atlast i am getting later values for each row.
ie urText and 2 in both row.
i need different values for different row
pls help me
|
|
|
|
|
i think putting myDemo.add(dm);
inside
foreach(datagridviewrow row in dgv.rows)
{
dm.text=row.cells[0].value.tostring();
dm.order=row.cells[1].value.tostring();
myDemo.add(dm);
}
may solve ur problem
rahul
|
|
|
|
|
Sorry Rahul
I already tried that.No Use(Same Result)
|
|
|
|
|
what about this
foreach(datagridviewrow row in dgv.rows)
{
demo dm=new demo();
dm.text=row.cells[0].value.tostring();
dm.order=row.cells[1].value.tostring();
myDemo.add(dm);
}
rahul
|
|
|
|
|
Thank u rahul
its working
|
|
|
|
|
There are two applications (actually it is one -server-client-). They connect each other using TCP/IP. When the client application sends restart command the server application runs cmd.exe with 'shutdown -r -f -t 0' parameters and there is no problem pc is being restarting, if pc is started with Administrator user. When we start the pc with another user not Administrator server client application runs cmd.exe the same way but it does not restarted.
A couple of things come to my mind but I don't know what and how I do, let me explaing;
1-)Do I need to set something on the pc which was done for Administrator user?
2-)or do I need to add something to parameters ('shutdown -r -f -t 0') to run the server application like 'Run as Administrator..' and I think the second comment will the key.
Many thanks.
Muharrem.
|
|
|
|
|
The account that runs the Shutdown command has to have the Shutdown priviledge. I take it you're trying to shutdown a Windows Server machine, which no normal user has the permissions to do. It can only be done by and Admin level account.
Instead of using the Shutdown command, you might want to change to using ExitWindowsEx[^] instead.
|
|
|
|
|
First of all many thanks for your help.
I changed my code like;
[DllImport("aygshell.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool ExitWindowsEx([MarshalAs(UnmanagedType.U4)]uint dwFlags, [MarshalAs(UnmanagedType.U4)]uint dwReserved);
[DllImport("aygshell.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool ExitWindowsEx([MarshalAs(UnmanagedType.U4)] ExitWindowsAction uFlags, [MarshalAs(UnmanagedType.U4)] uint dwReserved);
enum ExitWindowsAction : uint
{
EWX_LOGOFF = 0,
EWX_SHUTDOWN = 1,
EWX_REBOOT = 2,
EWX_FORCE = 4,
EWX_POWEROFF = 8
}
And I called the method
ExitWindowsEx(ExitWindowsAction.EWX_REBOOT, 0);
firstly I had an error "unable to load DLL" -0X8007007E-
and I found 'aygshell.dll' dll and copied it to C:\Windows\System32\aygshell.dll and also where my exe is.
And secondly I had an another error "An attempt was made to load a program with an incorret format" -0X8007000E-
What can I do, where is the wrong?
|
|
|
|
|
AYGSHELL is only available in Windows CE. Sorry, but I linked to the wrong version of the page. You're looking for this one[^].
|
|
|
|
|
final code is;
[Flags]
public enum ExitWindows : uint
{
// ONE of the following five:
LogOff = 0x00,
ShutDown = 0x01,
Reboot = 0x02,
PowerOff = 0x08,
RestartApps = 0x40,
// plus AT MOST ONE of the following two:
Force = 0x04,
ForceIfHung = 0x10,
}
[Flags]
enum ShutdownReason : uint
{
MajorApplication = 0x00040000,
MajorHardware = 0x00010000,
MajorLegacyApi = 0x00070000,
MajorOperatingSystem = 0x00020000,
MajorOther = 0x00000000,
MajorPower = 0x00060000,
MajorSoftware = 0x00030000,
MajorSystem = 0x00050000,
FlagUserDefined = 0x40000000,
FlagPlanned = 0x80000000
}
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason);
And I used the method;
ExitWindowsEx(ExitWindows.LogOff, ShutdownReason.MajorOther);(LogOff) It does work there is no problem but
ExitWindowsEx(ExitWindows.Reboot, ShutdownReason.MajorOther); Reboot It doesn't work.
I think there is something about 'AdjustTokenPrivileges' on page which you've sent me, but I couldn't integrated this part of code (I don't know where I have to write this code about 'AdjustTokenPrivileges' I've written something and I will be trying)
Although the remote pc is started Administrator user the method doesn't work with Reboot parameters.
Many Thanks for all.
|
|
|
|