Search Results

Search found 7140 results on 286 pages for 'mike tostring'.

Page 19/286 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • ASP.Net Gridview paging, pageindex always == 0.

    - by David Archer
    Hi all, Having a slight problem with my ASP.Net 3.5 app. I'm trying to get the program to pick up what page number has been clicked. I'm using ASP.Net's built in AllowPaging="True" function. It's never the same without code, so here it is: ASP.Net: <asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="Vertical" Width="960px" AllowSorting="True" EnableSortingAndPagingCallbacks="True" AllowPaging="True" PageSize="25" > <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#999999" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:GridView> C#: var fillTable = from ft in db.IncidentDatas where ft.pUserID == Convert.ToInt32(ClientList.SelectedValue.ToString()) select new { Reference = ft.pRef.ToString(), Date = ft.pIncidentDateTime.Value.Date.ToShortDateString(), Time = ft.pIncidentDateTime.Value.TimeOfDay, Premesis = ft.pPremises.ToString(), Latitude = ft.pLat.ToString(), Longitude = ft.pLong.ToString() }; if (fillTable.Count() > 0) { GridView1.DataSource = fillTable; GridView1.DataBind(); var IncidentDetails = fillTable.ToList(); for (int i = 0; i < IncidentDetails.Count(); i++) { int pageno = GridView1.PageIndex; int pagenostart = pageno * 25; if (i >= pagenostart && i < (pagenostart + 25)) { //Processing } } } Any idea why GridView1.PageIndex is always = 0? The thing is, the processing works correctly for the grid view.... it will always go to the correct paging page, but it's always 0 when I try to get the number. Help!

    Read the article

  • Problems with Json Serialize Dictionary<Enum, Int32>

    - by dbemerlin
    Hi, whenever i try to serialize the dictionary i get the exception: System.ArgumentException: Type 'System.Collections.Generic.Dictionary`2[[Foo.DictionarySerializationTest+TestEnum, Foo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' is not supported for serialization/deserialization of a dictionary, keys must be strings or object My Testcase is: public class DictionarySerializationTest { private enum TestEnum { A, B, C } public void SerializationTest() { Dictionary<TestEnum, Int32> data = new Dictionary<TestEnum, Int32>(); data.Add(TestEnum.A, 1); data.Add(TestEnum.B, 2); data.Add(TestEnum.C, 3); JavaScriptSerializer serializer = new JavaScriptSerializer(); String result = serializer.Serialize(data); // Throws } public void SerializationStringTest() { Dictionary<String, Int32> data = new Dictionary<String, Int32>(); data.Add(TestEnum.A.ToString(), 1); data.Add(TestEnum.B.ToString(), 2); data.Add(TestEnum.C.ToString(), 3); JavaScriptSerializer serializer = new JavaScriptSerializer(); String result = serializer.Serialize(data); // Succeeds } } Of course i could use .ToString() whenever i enter something into the Dictionary but since it's used quite often in performance relevant methods i would prefer using the enum. My only solution is using .ToString() and converting before entering the performance critical regions but that is clumsy and i would have to change my code structure just to be able to serialize the data. Does anyone have an idea how i could serialize the dictionary as <Enum, Int32>? I use the System.Web.Script.Serialization.JavaScriptSerializer for serialization.

    Read the article

  • Scala traits and implicit conversion confusion

    - by pr1001
    The following lines work when I enter them by hand on the Scala REPL (2.7.7): trait myTrait { override def toString = "something" } implicit def myTraitToString(input: myTrait): String = input.toString object myObject extends myTrait val s: String = myObject However, if I try to compile file with it I get the following error: [error] myTrait.scala:37: expected start of definition [error] implicit def myTraitToString(input: myTrait): String = input.toString [error] ^ Why? Thanks!

    Read the article

  • protobuf-net NOT faster than binary serialization?

    - by Ashish Gupta
    I wrote a program to serialize a 'Person' class using XMLSerializer, BinaryFormatter and ProtoBuf. I thought protobuf-net should be faster than the other two. Protobuf serialization was faster than XMLSerialization but much slower than the binary serialization. Is my understanding incorrect? Please make me understand this. Thank you for the help. Following is the output:- Person got created using protocol buffer in 347 milliseconds Person got created using XML in 1462 milliseconds Person got created using binary in 2 milliseconds Code below using System; using System.Collections.Generic; using System.Linq; using System.Text; using ProtoBuf; using System.IO; using System.Diagnostics; using System.Runtime.Serialization.Formatters.Binary; namespace ProtocolBuffers { class Program { static void Main(string[] args) { string XMLSerializedFileName = "PersonXMLSerialized.xml"; string ProtocolBufferFileName = "PersonProtocalBuffer.bin"; string BinarySerializedFileName = "PersonBinary.bin"; var person = new Person { Id = 12345, Name = "Fred", Address = new Address { Line1 = "Flat 1", Line2 = "The Meadows" } }; Stopwatch watch = Stopwatch.StartNew(); watch.Start(); using (var file = File.Create(ProtocolBufferFileName)) { Serializer.Serialize(file, person); } watch.Stop(); Console.WriteLine(watch.ElapsedMilliseconds.ToString()); Console.WriteLine("Person got created using protocol buffer in " + watch.ElapsedMilliseconds.ToString() + " milliseconds " ); watch.Reset(); watch.Start(); System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(person.GetType()); using (TextWriter w = new StreamWriter(XMLSerializedFileName)) { x.Serialize(w, person); } watch.Stop(); Console.WriteLine(watch.ElapsedMilliseconds.ToString()); Console.WriteLine("Person got created using XML in " + watch.ElapsedMilliseconds.ToString() + " milliseconds"); watch.Reset(); watch.Start(); using (Stream stream = File.Open(BinarySerializedFileName, FileMode.Create)) { BinaryFormatter bformatter = new BinaryFormatter(); //Console.WriteLine("Writing Employee Information"); bformatter.Serialize(stream, person); } watch.Stop(); Console.WriteLine(watch.ElapsedMilliseconds.ToString()); Console.WriteLine("Person got created using binary in " + watch.ElapsedMilliseconds.ToString() + " milliseconds"); Console.ReadLine(); } } [ProtoContract] [Serializable] public class Person { [ProtoMember(1)] public int Id {get;set;} [ProtoMember(2)] public string Name { get; set; } [ProtoMember(3)] public Address Address {get;set;} } [ProtoContract] [Serializable] public class Address { [ProtoMember(1)] public string Line1 {get;set;} [ProtoMember(2)] public string Line2 {get;set;} } }

    Read the article

  • Code in FOR loop not executed

    - by androniennn
    I have a ProgressDialog that retrieves in background data from database by executing php script. I'm using gson Google library. php script is working well when executed from browser: {"surveys":[{"id_survey":"1","question_survey":"Are you happy with the actual government?","answer_yes":"50","answer_no":"20"}],"success":1} However, ProgressDialog background treatment is not working well: @Override protected Void doInBackground(Void... params) { String url = "http://192.168.1.4/tn_surveys/get_all_surveys.php"; HttpGet getRequest = new HttpGet(url); Log.d("GETREQUEST",getRequest.toString()); try { DefaultHttpClient httpClient = new DefaultHttpClient(); Log.d("URL1",url); HttpResponse getResponse = httpClient.execute(getRequest); Log.d("GETRESPONSE",getResponse.toString()); final int statusCode = getResponse.getStatusLine().getStatusCode(); Log.d("STATUSCODE",Integer.toString(statusCode)); Log.d("HTTPSTATUSOK",Integer.toString(HttpStatus.SC_OK)); if (statusCode != HttpStatus.SC_OK) { Log.w(getClass().getSimpleName(), "Error " + statusCode + " for URL " + url); return null; } HttpEntity getResponseEntity = getResponse.getEntity(); Log.d("RESPONSEENTITY",getResponseEntity.toString()); InputStream httpResponseStream = getResponseEntity.getContent(); Log.d("HTTPRESPONSESTREAM",httpResponseStream.toString()); Reader inputStreamReader = new InputStreamReader(httpResponseStream); Gson gson = new Gson(); this.response = gson.fromJson(inputStreamReader, Response.class); } catch (IOException e) { getRequest.abort(); Log.w(getClass().getSimpleName(), "Error for URL " + url, e); } return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); Log.d("HELLO","HELLO"); StringBuilder builder = new StringBuilder(); Log.d("STRINGBUILDER","STRINGBUILDER"); for (Survey survey : this.response.data) { String x= survey.getQuestion_survey(); Log.d("QUESTION",x); builder.append(String.format("<br>ID Survey: <b>%s</b><br> <br>Question: <b>%s</b><br> <br>Answer YES: <b>%s</b><br> <br>Answer NO: <b>%s</b><br><br><br>", survey.getId_survey(), survey.getQuestion_survey(),survey.getAnswer_yes(),survey.getAnswer_no())); } Log.d("OUT FOR","OUT"); capitalTextView.setText(Html.fromHtml(builder.toString())); progressDialog.cancel(); } HELLO Log is displayed. STRINGBUILDER Log is displayed. QUESTION Log is NOT displayed. OUT FOR Log is displayed. Survey Class: public class Survey { int id_survey; String question_survey; int answer_yes; int answer_no; public Survey() { this.id_survey = 0; this.question_survey = ""; this.answer_yes=0; this.answer_no=0; } public int getId_survey() { return id_survey; } public String getQuestion_survey() { return question_survey; } public int getAnswer_yes() { return answer_yes; } public int getAnswer_no() { return answer_no; } } Response Class: public class Response { ArrayList<Survey> data; public Response() { data = new ArrayList<Survey>(); } } Any help please concerning WHY the FOR loop is not executed. Thank you for helping.

    Read the article

  • How can I parse a namespace using the SAX parser?

    - by Silvestri
    Hello, Using a twitter search URL ie. http://search.twitter.com/search.rss?q=android returns CSS that has an item that looks like: <item> <title>@UberTwiter still waiting for @ubertwitter android app!!!</title> <link>http://twitter.com/meals69/statuses/21158076391</link> <description>still waiting for an app!!!</description> <pubDate>Sat, 14 Aug 2010 15:33:44 +0000</pubDate> <guid>http://twitter.com/meals69/statuses/21158076391</guid> <author>Some Twitter User</author> <media:content type="image/jpg" height="48" width="48" url="http://a1.twimg.com/profile_images/756343289/me2_normal.jpg"/> <google:image_link>http://a1.twimg.com/profile_images/756343289/me2_normal.jpg</google:image_link> <twitter:metadata> <twitter:result_type>recent</twitter:result_type> </twitter:metadata> </item> Pretty simple. My code parses out everything (title, link, description, pubDate, etc.) without any problems. However, I'm getting null on: <google:image_link> I'm using Java to parse the RSS feed. Do I have to handle compound localnames differently than I would a more simple localname? This is the bit of code that parses out Link, Description, pubDate, etc: @Override public void endElement(String uri, String localName, String name) throws SAXException { super.endElement(uri, localName, name); if (this.currentMessage != null){ if (localName.equalsIgnoreCase(TITLE)){ currentMessage.setTitle(builder.toString()); } else if (localName.equalsIgnoreCase(LINK)){ currentMessage.setLink(builder.toString()); } else if (localName.equalsIgnoreCase(DESCRIPTION)){ currentMessage.setDescription(builder.toString()); } else if (localName.equalsIgnoreCase(PUB_DATE)){ currentMessage.setDate(builder.toString()); } else if (localName.equalsIgnoreCase(GUID)){ currentMessage.setGuid(builder.toString()); } else if (uri.equalsIgnoreCase(AVATAR)){ currentMessage.setAvatar(builder.toString()); } else if (localName.equalsIgnoreCase(ITEM)){ messages.add(currentMessage); } builder.setLength(0); } } startDocument looks like: @Override public void startDocument() throws SAXException { super.startDocument(); messages = new ArrayList<Message>(); builder = new StringBuilder(); } startElement looks like: @Override public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { super.startElement(uri, localName, name, attributes); if (localName.equalsIgnoreCase(ITEM)){ this.currentMessage = new Message(); } } Tony

    Read the article

  • keyboard layout direction

    - by mike
    hi, I would like to detect the direction of the current typing (input) language. I may detect the language by means of "GetKeyboardLayout", but then I'll have to check if it equals to Arabic or Hebrew and so on, is there any way just to detect the direction, i.e. left to right or right to left. thanks! mike.

    Read the article

  • Controls.remove() method not working in asp.net

    - by user279521
    I have a web app where the user can create dynamic textboxes at run time. When the user clicks SUBMIT, the form sends data to the database and I want remove the dynamic controls. The controls are created in the following code: Table tb = new Table(); tb.ID = "tbl"; for (i = 0; i < myCount; i += 1) { TableRow tr = new TableRow(); TextBox txtEmplName = new TextBox(); TextBox txtEmplEmail = new TextBox(); TextBox txtEmplPhone = new TextBox(); TextBox txtEmplPosition = new TextBox(); TextBox txtEmplOfficeID = new TextBox(); txtEmplName.ID = "txtEmplName" + i.ToString(); txtEmplEmail.ID = "txtEmplEmail" + i.ToString(); txtEmplPhone.ID = "txtEmplPhone" + i.ToString(); txtEmplPosition.ID = "txtEmplPosition" + i.ToString(); txtEmplOfficeID.ID = "txtEmplOfficeID" + i.ToString(); tr.Cells.Add(tc); tb.Rows.Add(tr); } Panel1.Controls.Add(tb); The Remove section of the code is: Table t = (Table)Page.FindControl("Panel1").FindControl("tbl"); foreach (TableRow tr in t.Rows) { for (i = 1; i < myCount; i += 1) { string txtEmplName = "txtEmplName" + i; tr.Controls.Remove(t.FindControl(txtEmplName)); string txtEmplEmail = "txtEmplEmail" + i; tr.Controls.Remove(t.FindControl(txtEmplEmail)); string txtEmplPhone = "txtEmplPhone" + i; tr.Controls.Remove(t.FindControl(txtEmplPhone)); string txtEmplPosition = "txtEmplPosition" + i; tr.Controls.Remove(t.FindControl(txtEmplPosition)); string txtEmplOfficeID = "txtEmplOfficeID" + i; tr.Controls.Remove(t.FindControl(txtEmplOfficeID)); } } However, the textboxes are still visible. Any ideas?

    Read the article

  • Object reference not set to an instance of an object

    - by MBTHQ
    Can anyone help with the following code? I'm trying to get data from the database colum to the datagridview... I'm getting error over here "Dim sql_1 As String = "SELECT * FROM item where item_id = '" + DataGridView_stockout.CurrentCell.Value.ToString() + "'"" Private Sub DataGridView_stockout_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView_stockout.CellMouseClick Dim i As Integer = Stock_checkDataSet1.Tables(0).Rows.Count > 0 Dim thiscur_stok As New System.Data.SqlClient.SqlConnection("Data Source=MBTHQ\SQLEXPRESS;Initial Catalog=stock_check;Integrated Security=True") ' Sql Query Dim sql_1 As String = "SELECT * FROM item where item_id = '" + DataGridView_stockout.CurrentCell.Value.ToString() + "'" ' Create Data Adapter Dim da_1 As New SqlDataAdapter(sql_1, thiscur_stok) ' Fill Dataset and Get Data Table da_1.Fill(Stock_checkDataSet1, "item") Dim dt_1 As DataTable = Stock_checkDataSet1.Tables("item") If i >= DataGridView_stockout.Rows.Count Then 'MessageBox.Show("Sorry, DataGridView_stockout doesn't any row at index " & i.ToString()) Exit Sub End If If 1 >= Stock_checkDataSet1.Tables.Count Then 'MessageBox.Show("Sorry, Stock_checkDataSet1 doesn't any table at index 1") Exit Sub End If If i >= Stock_checkDataSet1.Tables(1).Rows.Count Then 'MessageBox.Show("Sorry, Stock_checkDataSet1.Tables(1) doesn't any row at index " & i.ToString()) Exit Sub End If If Not Stock_checkDataSet1.Tables(1).Columns.Contains("os") Then 'MessageBox.Show("Sorry, Stock_checkDataSet1.Tables(1) doesn't any column named 'os'") Exit Sub End If 'DataGridView_stockout.Item("cs_stockout", i).Value = Stock_checkDataSet1.Tables(0).Rows(i).Item("os") Dim ab As String = Stock_checkDataSet1.Tables(0).Rows(i)(0).ToString() End Sub I keep on getting the error saying "Object reference not set to an instance of an object" I dont know where I'm going wrong. Help really appreciated!!

    Read the article

  • Emails sent using Flex app are delayed

    - by user363825
    I'm currently building an application in Flex that utilizes SMTP Mailer to automatically send out emails to the user when a particular condition is satisfied. The application checks this condition every 30 seconds. The condition is satisfied based on new records being returned from a database table. The problem is as follows: When the condition is first satisfied, the email is delivered to the user with no issues. The second time the condition is satisfied, the email is not delivered. In the smtp logs, the delivery attempt appears to get hung up on the following line: 354 Start mail input; end with <CRLF>.<CRLF> No error codes are present in the smtp logs, but I do trace the following event from the SMTP Mailer class: [Event type="mailError" bubbles=false cancelable=false eventPhase=2] When the condition is satisfied a third time, the email that was not delivered when the condition was satisfied the previous time is now delivered, along with the email for this instance. This pattern then repeats itself, with the next email not being sent followed by two emails being sent simulatneously when the condition is met again. The smtp server being used is Windows 2003, on an internal network. The email is being sent to an outlook account hosted on an exchange server that is also on this internal network. Here is the actionscript code that creates the SMTPMailer object: public var testMail:SMTPMailer = null; public function alertNotify() { Security.loadPolicyFile("crossdomain.xml"); this.testMail = new SMTPMailer("myserver.ec.local",25); this.testMail.addEventListener(SMTPEvent.MAIL_SENT, onEmailEvent); this.testMail.addEventListener(SMTPEvent.MAIL_ERROR, onEmailError); this.testMail.addEventListener(SMTPEvent.DISCONNECTED, onEmailConn); this.testMail.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onEmailError); } Here is the code that creates the email body and calls the method to send the email: public function alertUser(emailAC:ArrayCollection):void { trace ("In alertUser() before send, testMail.connected = " + testMail.connected.toString()); var testStr:String = " Key Location Event Type Comment Update Time "; for each (var event:rEntity in emailAC) { testStr = testStr + "" + event.key.toString() + "" + event.xml.address.toString() + " " + [email protected]() + "" + [email protected]() + "" + [email protected]() + "" + event.xml.attribute("update-time").toXMLString() + ""; } testStr = testStr + ""; testMail.flush(); testMail.sendHTMLMail("[email protected]","[email protected]","Event Notification",testStr); } Really not sure where the email that gets hung up is being stored until it is finally sent.... Any suggestions as to how to begin to remedy this issue would be much appreciated.

    Read the article

  • How Pick a Column Value from a ListView Row - C#.NET

    - by peace
    How can i fetch the value 500 to a variable from the selected row? One solution would be to get the row position number and then the CustomerID position number. Can you please give a simple solution. SelectedItems means selected row and SubItems means the column values, so SelectedItem 0 and SubItem 0 would represent the value 500. Right? This is how i populate the listview: for (int i = 0; i < tempTable.Rows.Count; i++) { DataRow row = tempTable.Rows[i]; ListViewItem lvi = new ListViewItem(row["customerID"].ToString()); lvi.SubItems.Add(row["companyName"].ToString()); lvi.SubItems.Add(row["firstName"].ToString()); lvi.SubItems.Add(row["lastName"].ToString()); lstvRecordsCus.Items.Add(lvi); }

    Read the article

  • View status of service running on remote machine

    - by tunwn
    The conditions are - I don't have administrator privilege - I want to see the status of a service in remote machine (server) I use the following code (vb.net with framework 2.0) to see the status Dim sqlSvc As ServiceController Svc = New ServiceController(My.Settings.serviceName, My.Settings.machineName) If sqlSvc.Status.ToString.Equals("Running") Then displayStatus("success", sqlSvc.Status.ToString) Else displayStatus("error", sqlSvc.Status.ToString) End If When running the code, InvalidOperationException is raised and found out that I need admin right in the server. Can I lookup the status of the service without having admin right in remote machine ?

    Read the article

  • How to know the next temp file to be created in windows?

    - by Mike
    I am by no means a programmer but currently am wondering if an application creates a temp file that windows names. For example the file it creates is tmp001, is there a way i can take that name tmp001 and ask windows to give me the next temp file it would create before it creates it. Thanks, Mike

    Read the article

  • Page Render Time in ASP.MVC in trace

    - by Pankaj
    Hello Everyone I want to check render time of each page in asp.net mvc application. i am using asp.net tracing. i have override the OnActionExecuting and OnActionExecuted methods on the BaseController class. protected override void OnActionExecuting(ActionExecutingContext filterContext) { string controler = filterContext.RouteData.Values["controller"].ToString(); string action = filterContext.RouteData.Values["action"].ToString(); StartTime =System.DateTime.Now; System.Diagnostics.Trace.Write(string.Format("Start '{0}/{1}' on: {2}", controler, action, System.DateTime.Now.UtilToISOFormat())); } protected override void OnActionExecuted(ActionExecutedContext filterContext) { string controler = filterContext.RouteData.Values["controller"].ToString(); string action = filterContext.RouteData.Values["action"].ToString(); var totalTime = System.DateTime.Now - this.StartTime; System.Diagnostics.Trace.Write(totalTime.ToString()); System.Diagnostics.Trace.Write(string.Format("End '{0}/{1}' on: {2}", controler, action, System.DateTime.Now.UtilToISOFormat())); } in OnActionExecuted method i get total time. how can i show this time in my http://localhost:51335/Trace.axd report?

    Read the article

  • Converting Negative Decimal To String Loses the -

    - by coffeeaddict
    I'm required to send in a negative myDecimalValue.ToString("C"); The problem is if myDecimalValue is a negative, lets say -39, after conversion I'm getting $39.00 as the string not $39.00. So I'm not sure how to go about this. This is the utility method that takes in the decimal. If the decimal is negative, I want the ToString to show a negative public static BasicAmountType CreateBasicAmount(string amount, CurrencyCodeType currencyType) { BasicAmountType basicAmount = new BasicAmountType { currencyID = currencyType, Value = amount }; return basicAmount; } I could go either way, a C or F2, all I care is about getting that negative sign intothe string if the incoming decimal is negative. I suppose there's no way to do this unless I check for negativity inside my utility method here. I can't just send a negative number and expect the ToString to work and for the ToSTring to automatically see that the decimal is negative incoming?

    Read the article

  • XAML get new width and height for Canvas

    - by Jack Navarro
    I have searched through many times but have not seen this before. Probably really simple question but can't wrap my head around it. Wrote a VSTO add-in for Excel that draws a Grid dynamically. Then launches a new window and replaces the contents of the Canvas with the generated Grid. The problem is with printing. When I call the print procedure the canvas.height and canvas.width returned is the old value prior to replacing it with the grid. Sample: string="<Grid Name=\"CanvasGrid\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">..Lots of stuff..</Grid>"; // Launch new window and replace the Canvas element WpfUserControl newWindow = new WpfUserControl(); newWindow.Show(); //To test MessageBox.Show(myCanvas.ActualWidth.ToString()); //return 894 Grid testGrid = myCanvas.FindName("CanvasGrid") as Grid; MessageBox.Show("Grid " + testGrid.ActualWidth.ToString()); //return 234 StringReader stringReader = new StringReader(LssAllcChrt); XmlReader xmlReader = XmlReader.Create(stringReader); Canvas myCanvas = newWindow.FindName("GrphCnvs") as Canvas; myCanvas.Children.Clear(); myCanvas.Children.Add((UIElement)XamlReader.Load(xmlReader)); //To test MessageBox.Show(myCanvas.ActualWidth.ToString()); //return 894 but should be much larger the Grid spans all three of my screens Grid testGrid = myCanvas.FindName("CanvasGrid") as Grid; MessageBox.Show("Grid " + testGrid.ActualWidth.ToString()); //return 234 but should be much larger the Grid spans all three of my screens //Run code from WpfUserControl.cs after it loads from button click Grid testGrid = canvas.FindName("CanvasGrid") as Grid; MessageBox.Show("Grid " + testGrid.ActualWidth.ToString()); //return 234 but should be much larger the Grid spans all three of my screens So basically I have no way of telling what my new width and height are.

    Read the article

  • Bind Config section to DataTable using c#

    - by srk
    I have the following config section in my app.config file and the code to iterate through config section to retrieve the values. But i want to save the values of config section to a datatable in a proper structure. How ? I want to show all the values in datagridview with appropriate columns. <configSections> <section name="ServerInfo" type="System.Configuration.IConfigurationSectionHandler" /> </configSections> <ServerInfo> <Server id="1"> <Name>SRUAV1</Name> <key> 1 </key> <IP>10.1.150.110</IP> <Port>7901</Port> </Server> <Server id="2"> <Name>SRUAV2</Name> <key> 4 </key> <IP>10.1.150.110</IP> <Port>7902</Port> </Server> <Server id="3"> <Name>SRUAV3</Name> <key> 6 </key> <IP>10.1.150.110</IP> <Port>7904</Port> </Server> </ServerInfo> Code : public void GetServerValues(string strSelectedServer) { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); ConfigurationSection section = config.GetSection("ServerInfo"); XmlDocument xml = new XmlDocument(); xml.LoadXml(section.SectionInformation.GetRawXml()); string temp = ""; XmlNodeList applicationList = xml.DocumentElement.SelectNodes("Server"); for (int i = 0; i < applicationList.Count; i++) { object objAppId = applicationList[i].Attributes["id"]; int iAppId = 0; if (objAppId != null) { iAppId = Convert.ToInt32(applicationList[i].Attributes["id"].Value); } temp = BuildServerValues(applicationList[i]); } } public string BuildServerValues(XmlNode applicationNode) { for (int i = 0; i < applicationNode.ChildNodes.Count; i++) { if (applicationNode.ChildNodes.Item(i).Name.ToString().Equals("Name")) { strServerName = applicationNode.ChildNodes.Item(i).InnerXml.ToString(); } if (applicationNode.ChildNodes.Item(i).Name.ToString().Equals("IP")) { strIP = applicationNode.ChildNodes.Item(i).InnerXml.ToString(); } if (applicationNode.ChildNodes.Item(i).Name.ToString().Equals("Port")) { strPort = applicationNode.ChildNodes.Item(i).InnerXml.ToString(); } } return strServerName; }

    Read the article

  • Javascript Regex multiple group matches in pattern

    - by mummybot
    I have a question for a Javascript regex ninja: How could I simplify my variable creation from a string using regex? I currently have it working without using any grouping, but I would love to see a better way! The string is: var url = 'resources/css/main.css?detect=#information{width:300px;}'; The code that works is: var styleStr = /[^=]+$/.exec(url).toString(); var id = /[^\#][^\{]+/.exec(styleStr).toString(); var property = /[^\{]+/.exec(/[^\#\w][^\:]+/.exec(styleStr)).toString(); var value = /[^\:]+/.exec(/[^\#\w\{][^\:]+[^\;\}]/.exec(styleStr)).toString(); This gives: alert(id) //information alert(property) //width alert(value) //300px Any takers?

    Read the article

  • System.Threading.Timer Doesn't Trigger my TimerCallBack Delegate

    - by Tom Kong
    Hi, I am writing my first Windows Service using C# and I am having some trouble with my Timer class. When the service is started, it runs as expected but the code will not execute again (I want it to run every minute) Please take a quick look at the attached source and let me know if you see any obvious mistakes! TIA using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess; using System.Text; using System.Threading; using System.IO; namespace CXO001 { public partial class Service1 : ServiceBase { public Service1() { InitializeComponent(); } /* * Aim: To calculate and update the Occupancy values for the different Sites * * Method: Retrieve data every minute, updating a public value which can be polled */ protected override void OnStart(string[] args) { Daemon(); } public void Daemon() { TimerCallback tcb = new TimerCallback(On_Tick); TimeSpan duetime = new TimeSpan(0, 0, 1); TimeSpan interval = new TimeSpan(0, 1, 0); Timer querytimer = new Timer(tcb, null, duetime, interval); } protected override void OnStop() { } static int[] floorplanids = new int[] { 115, 114, 107, 108 }; public static List<Record> Records = new List<Record>(); static bool firstrun = true; public static void On_Tick(object timercallback) { //Update occupancy data for the last minute //Save a copy of the public values to HDD with a timestamp string starttime; if (Records.Count > 0) { starttime = Records.Last().TS; firstrun = false; } else { starttime = DateTime.Today.AddHours(7).ToString(); firstrun = true; } DateTime endtime = DateTime.Now; GetData(starttime, endtime); } public static void GetData(string starttime, DateTime endtime) { string connstr = "Data Source = 192.168.1.123; Initial Catalog = Brickstream_OPS; User Id = Brickstream; Password = bstas;"; DataSet resultds = new DataSet(); //Get the occupancy for each Zone foreach (int zone in floorplanids) { SQL s = new SQL(); string querystr = "SELECT SUM(DIRECTIONAL_METRIC.NUM_TO_ENTER - DIRECTIONAL_METRIC.NUM_TO_EXIT) AS 'Occupancy' FROM REPORT_OBJECT INNER JOIN REPORT_OBJ_METRIC ON REPORT_OBJECT.REPORT_OBJ_ID = REPORT_OBJ_METRIC.REPORT_OBJECT_ID INNER JOIN DIRECTIONAL_METRIC ON REPORT_OBJ_METRIC.REP_OBJ_METRIC_ID = DIRECTIONAL_METRIC.REP_OBJ_METRIC_ID WHERE (REPORT_OBJ_METRIC.M_START_TIME BETWEEN '" + starttime + "' AND '" + endtime.ToString() + "') AND (REPORT_OBJECT.FLOORPLAN_ID = '" + zone + "');"; resultds = s.Go(querystr, connstr, zone.ToString(), resultds); } List<Record> result = new List<Record>(); int c = 0; foreach (DataTable dt in resultds.Tables) { Record r = new Record(); r.TS = DateTime.Now.ToString(); r.Zone = dt.TableName; if (!firstrun) { r.Occupancy = (dt.Rows[0].Field<int>("Occupancy")) + (Records[c].Occupancy); } else { r.Occupancy = dt.Rows[0].Field<int>("Occupancy"); } result.Add(r); c++; } Records = result; MrWriter(); } public static void MrWriter() { StringBuilder output = new StringBuilder("Time,Zone,Occupancy\n"); foreach (Record r in Records) { output.Append(r.TS); output.Append(","); output.Append(r.Zone); output.Append(","); output.Append(r.Occupancy.ToString()); output.Append("\n"); } output.Append(firstrun.ToString()); output.Append(DateTime.Now.ToFileTime()); string filePath = @"C:\temp\CXO.csv"; File.WriteAllText(filePath, output.ToString()); } } }

    Read the article

  • Behavior of virtual function in C++

    - by Summer_More_More_Tea
    Hi everyone: I have a question, here are two class below: class Base{ public: virtual void toString(); // generic implementation } class Derive : public Base{ public: ( virtual ) void toString(); // specific implementation } The question is: If I wanna subclass of class Derive perform polymophism using a pointer of type Base, is keyword virtual in the bracket necessary? If the answer is no, what's the difference between member function toString of class Derive with and without virtual?

    Read the article

  • How can I find all items beginning with a or â?

    - by Malcolm Frexner
    I have a list of items that are grouped by their first letter. By clicking a letter the user gets alle entries that begin with that letter. This does not work for french. If I choose the letter a, items with â are not returned. What is a good way to return items no matter if they have an accent or not? <% char alphaStart = Char.Parse("A"); char alphaEnd = Char.Parse("Z"); %> <% for (char i = alphaStart; i <= alphaEnd; i++) { %> <% char c = i; %> <% var abcList = Model.FaqList.Where(x => x.CmsHeader.StartsWith(c.ToString())).ToList(); %> <% if (abcList.Count > 0 ) { %> <div class="naviPkt"> <a id="<%= i.ToString().ToUpper() %>" class="naviPktLetter" href="#<%= i.ToString().ToLower() %>"><%= i.ToString().ToUpper() %></a> </div> <ul id="menuGroup<%= i.ToString().ToUpper() %>" class="contextMenu" style="display:none;"> <% foreach (var info in abcList) { %> <li class="<%= info.CmsHeader%>"> <a id="infoId<%= info.CmsInfoId%>" href="#<%= info.CmsInfoId%>" class="abcEntry"><%= info.CmsHeader%></a> </li> <% } %> </ul> <% } %> <% } %>

    Read the article

  • Possible for C++ template to check for a function's existence?

    - by andy
    Is it possible to write a C++ template that changes behavior depending on if a certain member function is defined on a class? Here's a simple example of what I would want to write: template<class T> std::string optionalToString(T* obj) { if (FUNCTION_EXISTS(T->toString)) return obj->toString(); else return "toString not defined"; } So if class T has "toString" defined then it uses it, otherwise it doesn't. The magical part that I don't know how to do is the "FUNCTION_EXISTS" part.

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >