|
I'm sure the answer to this is obvious, but I haven't been able to find an example of this yet...
I have a datagrid that I have made editable. How do I get rid of the columns for a row that is editable, but leave the columns on all the other datagrid rows?
[Edit] This is for a Website so I'm looking for a solution for the Web DataGrid control [/Edit]
|
|
|
|
|
You'll need to create a DataGridTableStyle for you grid. This should get you started:
DataGridTableStyle style = new DataGridTableStyle();<br />
style.MappingName = "Table";
<br />
DataGridColumnStyle Style1 = new DataGridTextBoxColumn();<br />
Style1.Width = 100;
Style1.MappingName = "TableColumn1";
Style1.HeaderText = "Column1";
<br />
DataGridColumnStyle Style2 = new DataGridTextBoxColumn();<br />
Style2.Width = 100;
Style2.MappingName = "TableColumn2";
Style2.HeaderText = "Colunn2";
<br />
style.GridColumnStyles.AddRange<br />
(<br />
new DataGridColumnStyle[]<br />
{<br />
Style1, Style2<br />
}<br />
);<br />
<br />
dataGrid1.TableStyles.Add(style);
As you can see, you can put any columns in your datagrid from your source that you choose, and omit the rest. You can do a lot with the datagrid, but this is a good starting point.
|
|
|
|
|
I guess I forgot to mention that I'm dealing we the Web DataGrid and not the Windows Forms datagrid. Thanks for the reply though. I couldn't find DatGridColumnStyle for the Web DataGrid.
|
|
|
|
|
Hi,
If I send a dataset to a dataadapter to update a database the second time after its been disconnected from the dataadapter will it pick up only the rows that need to be added to the database and not the ones already in the database? and will this also update rows in database that have changes in existing rows? I am retrieving a dataset from file and adding rows to it then feeding the new rows to the dataadapter to update DB but only want the new rows to be added and not of course existing ones.
Thanks,
JJ
|
|
|
|
|
If you have all the command properties set to a valid command object, then the DataAdapter will only update existing rows, insert new rows, and delete removed rows. Make sure you do not call DataSet.AcceptChanges yourself, or the DataAdapter will not see any changes. You should also combine your INSERT statement with a SELECT statement (separated by a semi-colon) so that auto-filled fields are updated in the DataSet .
If you're marshaling the DataSet across remoting boundaries, you might consider calling DataSet.GetChanges and send only the DataSet containing those changes. You would then, of course, have to call DataSet.Merge to merge the changes. This is really only useful when you need to marshal the DataSet across remoting boundaries.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Heath,
Ok the DataAdapter is in a web service on the same pc as the database. I am sending the dataset over the network to the web server. Does this constitute going across remoting bounderies?
Thanks,
JJ
|
|
|
|
|
No. Going across remoting boundaries would be like sending the DataSet to a Web Service from a client proxy, or to a Remoting object. There's other examples, too, but if the DataAdapter is just issueing commands based on the DataSet changes, that is normal behavior.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Maybe you misunderstood my design. I am sending a dataset to the web service from a PDA and the web service is updating the DB. So I would assume I am going across remoting boundaries, correct?
JJ
|
|
|
|
|
You said,If I send a dataset to a dataadapter to update a database... I saw nothing in there about sending a DataSet across the wire.
Then yes, the client should call DataSet.GetChanges and send the returned DataSet to the Web Service. If you get a DataSet back with the changes (don't expect the method to modify your instance - one has to be returned), then call DataSet.Merge on the original database, passing the DataSet you got back from the Web Service as the parameter. You should call Dispose on the DataSet you get back from the Web Service to free-up some memory.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
k Thanks,
JJ
|
|
|
|
|
Sorry to ask a Crystal Report question in this forum, but it is being used in a C# application. When I preview a report using the viewer, and then hit the print button...for some reason the viewer is squaring the number of copies I am trying to print. For instance, if I try to print 1 copy, I get 1 copy. 2 copies will print 4 documents. 3 copies will print 9 documents, and so on. Now I'm not doing anything special in my code, just using the print features that are embedded into the Crystal Report Viewer. Has anybody had this happen? Any ideas on what I might do to remedy this? Am I just an idiot? A little help please.
Also, along those same lines...some reports are created in landscape mode. Any clue how to set the print dialog to automatically print in landscape using the Crystal Report Viewer?
Thanks, that's all the questions I have for now...hope somebody can help me out! 
|
|
|
|
|
Im converting some older vb code to c#. In the visual basic code, there is a select case statement that evaluates whether or not a single character is equal to multiple chr() statements, such as chr(243), ect. I can't remember exactly how to do this in c#, replace the chr() function I mean. If anyone could jog my memory it would be greatly appreciated.
Thanks,
Ryan
|
|
|
|
|
You could use something like this:
char myChar = something;
switch(myChar)
{
case (char)88:
break;
case (char)98:
break;
case (char)100:
case (char)101:
case (char)102:
break;
default:
break;
}
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
It would be faster to convert the char to an int used in the switch statement. Far less casts would be required.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
True...I hadn't thought of that. Thanks! That's what I get for writing code on an empty stomach!
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
How did you implement the interface? If you used an explicit interface implementation like so:
void UCOMIPersistFile.GetClassID(out Guid pClassID)
{
} ...then you need to cast your class (this ) to UCOMIPersistFile in order to call the methods:
((UCOMIPersistFile)this).GetClassID(out someGuid); Note that you really don't use this interface in your own class, though. Your class implements this interface so that COM clients can get persisted data or write persisted data that your implementation saves to a file (hence IPersistFile ). If you want your class to use your implementation instead of duplicating it, then I recommend you define protected or private methods that actually read/write data and have your Load and Save methods call those from your explicit interface implementation. This will avoid the performance penalties of casting your object to UCOMIPersistFile just to call the method.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Following from the responses I got yesterday, here and elsewhere, I have now managed to create an EventLog by using the System.Diagnostics.EventLogInstaller class in my Windows Service. I have overridden the Install method to write out a method to the EventLog saying that the service is being installed. This works.
However, when I attempt to call SourceExists while the service is running it throws a SecurityException that says "Requested registry access is not allowed". (The service is running in a restricted account, and I would prefer not to use impersonation because that would open up extra security holes that I'd rather not deal with)
If I try again, but without the check for SourceExists I get the same exception when I use WriteEntry().
Any help would be appreciated.
Cheers,
Andy.
|
|
|
|
|
Your going to have to give the account the rights it needs. Either through impersonation or by increasing the rights of the account the service runs under.
How is this user account being restricted? Group Policy? Are there any other services/users using this account?
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
At the moment the account is based on a standard user. We want to restrict it as much as possible for security so it should only be able to run the service, access two directories and their subdirectoris where it gets and puts files, access to SQL Server and it must be able to write to the EventLog. The account will be used for nothing else. Essentially, it exists to do one job and one job only.
I cannot believe that it requires SYSTEM privileges to write to a custom log. I could understand if the situation was: creating a custom log and telling it that only users of a specific account or role are permitted to write to it.
|
|
|
|
|
It doesn't require SYSTEM priv's. Is this user account a member of any of the local User's groups?. The 'User' group is probably the minimum it needs to do this. If the user is not a member of any groups, I could see this problem occuring. but, of course, I can't test it where I'm at right now...
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello,
I'm trying to delete a node in my Xml-file like this:
xml.Load(filePath);
string pad = "//exceptions[@company='RLS']";
XmlNode delete = xml.SelectSingleNode(pad);
xml.DocumentElement.RemoveChild(delete);
but then i get a mistake like "The node to be removed is not a child of this node."
What can i do to delete the node?
The xml-file looks like this
<pack version="1.0">
<com>
<main>
<tests>
<test name="programs">independent</test>
</tests>
</main>
<exceptions company="RLS">
<tests>
<extest name="settings">independent</extest>
</tests>
</exceptions>
</com>
</pack>
|
|
|
|
|
Try the following:
<br />
doc.Load(filePath);<br />
string pad = "//exceptions[@company='RLS']";<br />
XmlNode node = doc.SelectSingleNode(pad);<br />
node.ParentNode.RemoveChild(node);<br />
Good luck.
[Modified Version]
<br />
doc.Load(filePath);<br />
string pad = "//exceptions[@company='RLS']";<br />
XmlNode node = doc.SelectSingleNode(pad);<br />
if(node!=null)<br />
{<br />
XmlNode parent = node.ParentNode;<br />
if(parent!=null) parent.RemoveChild(node);<br />
}<br />
My articles and software tools
|
|
|
|
|
|
using sql2000 reporting services?
|
|
|
|