Try;
string name = sqlcommRights.ExecuteScalar().ToString();
Though, Its a good idea to check the result isnt null before trying to access it.
Regards, Gareth. (FKA gareth111)
Try;
string name = sqlcommRights.ExecuteScalar().ToString();
Though, Its a good idea to check the result isnt null before trying to access it.
Regards, Gareth. (FKA gareth111)
Solved.
Regards, Gareth. (FKA gareth111)
I've changed my idea to have to have 2 stack panels, as this seems more fitting.
Regards, Gareth. (FKA gareth111)
Regards, Gareth. (FKA gareth111)
I am new to WPF, so bear with him. I want to have a GridView with 2 columns, displaying custom controls, which has X amount of rows. The data i am given is in a list format, which i then need to display as follows: i want to insert item 1 in column 1 and item 2 in column 2 for row 1. And then item 3 in column 1 and item 4 in column 2 for row 2, and so on - (Think of it a bit like a photo gallery) The custom control will display the details for each item, which i have already created. The problem i have is, how do i bind the data to the GridView. My initial idea was to split the data into rows, i.e.: have several lists, that contain 2 items. This allows me to know that item 1 is for column 1 and item 2 is for column 2, i can then work my way through all the lists and end up with all the rows populated with the custom controls. However, i cant work out how to programmtically add a new row, which should have a control in each column. Am i going about it the right way? Or barking up the wrong tree... Hopefully i've made sense. Cheers.
Regards, Gareth. (FKA gareth111)
Cool cheers!
Regards, Gareth. (FKA gareth111)
Cheers for your reply Luc, informative as always :) I am going to contact the 3rd party as well, as you say, i might be doing all this work for nothing if their end has limitations.
Regards, Gareth. (FKA gareth111)
Below is the code i've done from your example. The only bit i am unsure about is the waithandle. I know what/how to use them, but am unsure how it works in this scenario. Why would i want to hold the thread at a point?, is it just to save cpu cycles so it doesnt keep checking if the queue is empty?
public void AddImageRequestToQueue(string isbn)
{
Contract.Requires(!string.IsNullOrEmpty(isbn));
lock (\_queuePadLock)
{
\_imageRequests.Enqueue(isbn);
}
}
private void ProcessImageQueue()
{
do
{
if (\_imageRequests.Count > 0)
{
string isbn = string.Empty;
lock (\_queuePadLock)
{
isbn = \_imageRequests.Dequeue();
}
IImageResult imageResult = GetImage(isbn, ImageSize.Small);
OnProcessImageCompleted(new ProcessImageCompletedEventArgs(imageResult.Image, imageResult.ISBN));
Thread.Sleep(SleepTime);
}
}
while (true);
}
Regards, Gareth. (FKA gareth111)
The client is not a web browser, its a C# windows service. Sorry i did not make that clear.
Regards, Gareth. (FKA gareth111)
I have a web service that recieves calls from a number of clients (600 and growing). This calls a 3rd party web service to return some image data, which is then sent to the client. If i spam the 3rd party service with several calls at once (around 20+), it grinds to a halt, and takes over 2 seconds per call to return, when it normally takes 0.3 seconds on a single call. I noticed that if i throttle the calls (added a sleep of 500ms between each web request), the 3rd party runs fine. The question is, whats the best way/how can i implement a throttling system in my code, so if i receive several calls on different threads, i dont send them all at once, but que them up, so the 3rd party server has time to respond.
Regards, Gareth. (FKA gareth111)
It wouldnt work in the UK, since they pay someone to look through every image and verify that its correct. But it would be nice if it did...
Regards, Gareth. (FKA gareth111)
Problem solved. The HiddenField was always returning empty, even if i set it in the code behind. It was because it was located in a panel. Weird, not sure why, but once i moved it from one part of the page to the top (outside of the panel), it worked.
Regards, Gareth. (FKA gareth111)
No one got any ideas?, Someone must of had to create a "Confirm" dialog in jQuery and display some data from code behind before...
Regards, Gareth. (FKA gareth111)
modified on Tuesday, December 29, 2009 11:06 AM
So i am making a "Delete" button, which is on a gridview. The link calls some javascript, updates the hiddenfield value and then opens a jQuery dialog. In the dialog, there is a "Yes", "No" options. If the user clicks "Yes", i get the value of the hiddenfield and delete the record. Button;
<a href="#" onclick='LoadDialog(<%# Eval("AccountId") %>)'>Delete</a>
Javascript;
function LoadDialog(accountId) {
$('#<%= HiddenFieldAccountId.ClientID %>').attr('value', accountId);
$('#dialog').dialog('open');
return false;
}
Dialog;
<div id="dialog" title="Delete Account">
Are you sure you wish to delete this account?<br /><br />
<asp:HiddenField ID="HiddenFieldAccountId" runat="server" />
<asp:LinkButton ID="LinkButtonDelete" runat="server" onclick="LinkButtonDelete_Click">Yes</asp:LinkButton> |
<a href="#" onclick="UnloadDialog()">No</a>
</div>
When the "Yes" (LinkButtonDelete) is clicked, i step into the code and look at the hidden field, and this is where i come to the problem. The hidden field value is empty. I've added an alert message to the 'LoadDialog' javascript, and i know the account id is set, its just the code behind cant see it is.
Regards, Gareth. (FKA gareth111)
I am reading in some XML using the below code. The problem is when i attempt to get out the values for each Item, i get the same values again, ie: Debug prints out
Code = A123
Quantity = 10
using (TextReader textReader = new StringReader(xml))
using (XmlReader xmlReader = new XmlTextReader(textReader))
{
XPathDocument xPathDocument = new XPathDocument(xmlReader);
//Create navigator to get nodes out
XPathNavigator xPathNavigator = xPathDocument.CreateNavigator();
XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(xPathNavigator.NameTable);
xmlNamespaceManager.AddNamespace("ns", "OrderSchema");
//Get the order items
XPathExpression xPathExpressionItems = xPathNavigator.Compile("//ns:Order//ns:Items");
xPathExpressionItems.SetContext(xmlNamespaceManager);
XPathNodeIterator xPathNodeIteratorItems = xPathNavigator.Select(xPathExpressionItems);
do
{
string code = xPathNodeIteratorItems.Current.SelectSingleNode("//ns:Code", xmlNamespaceManager).ToString();
string quantity = xPathNodeIteratorItems.Current.SelectSingleNode("//ns:Quantity", xmlNamespaceManager).ToString();
System.Diagnostics.Debug.WriteLine("code == " + code);
System.Diagnostics.Debug.WriteLine("quantity == " + quantity);
System.Diagnostics.Debug.WriteLine("----");
}
while (xPathNodeIteratorItems.MoveNext());
}
Heres the xml i am reading in:
<?xml version="1.0" encoding="UTF-8" ?>
<Order>
<Items>
<Item>
<Code>A123</Code>
<Quantity>10</Quantity>
</Item>
<Item>
<Code>A456</Code>
<Quantity>5</Quantity>
</Item>
</Items>
</Order>
Any ideas what i am doing wrong?
Regards, Gareth. (FKA gareth111)
The app is going to be very small. All it does is watch a folder, if new files are created, alert the user and then the user runs something in the program. At the moment it is using 11k of memory, so i dont think this is an issue. Its also an internal app, so i know what systems it will be run on, and they are fast.
Regards, Gareth. (FKA gareth111)
Cheers. I changed it to "NotifyFilters.FileName", as i am only interested in new files being created.
Regards, Gareth. (FKA gareth111)
This is the first time i've used a FileSystemWatcher, so i might well be doing something very basic wrong. The code below is what i use to start the FileSystemWatcher.
_fileSystemWatcher = new FileSystemWatcher(path, "*.sql");
_fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite;
_fileSystemWatcher.Created += new FileSystemEventHandler(FileSystemWatcher_Created);
_fileSystemWatcher.Error += new ErrorEventHandler(FileSystemWatcher_Error);
_fileSystemWatcher.EnableRaisingEvents = true;
But, i never seem to get an events raised. The path is set to the correct folder and i am creating files with an sql extension when my program runs, so i thought i would see some info. I am running Win7, if thats any help...
Regards, Gareth. (FKA gareth111)
Frank, The problem with my code was that i was doing an:
If (InvokeRequired)
On the main control class, which always returned false when the problem occurred, but the actaul TreeView control was returned true for InvokeRequired. Thus, the solution was to invoke on the TreeView control. If you need some more info, just say.
Regards, Gareth. (FKA gareth111)
I don't send status messages, I only send data that is required.
Regards, Gareth. (FKA gareth111)