Search Results

Search found 8446 results on 338 pages for 'dynamic cast'.

Page 100/338 | < Previous Page | 96 97 98 99 100 101 102 103 104 105 106 107  | Next Page >

  • Default Sorting in DynamicData

    - by Jens A.
    I am using DynamicData in the version that shipped with VS2008. In the default List view, the data is sorted by order of entry into the database. I'd like to get it sorted by a field of a specific name (descending). As a last resort I tried to use the OrderByParameter of the LinqDataSource with a QueryStringParameter, but I could not get it to sort anything. =) Is there an easy way to accomplish this?

    Read the article

  • javascript - how to call a function newly added from ajax

    - by strike_noir
    I have a coding difficulty which have been asked in this forum before: Calling a JavaScript function returned from a Ajax response But I didn't find the answers quite satisfying. To be more precise of the problem I'm dealing, here is the details: I dynamically load a document (HTML and javascript) using jquery var url = 'document.php'; $('#container').load(url); And then I want to call the functions from that document.php. Due to my requirement, I don't want to call the function after the documents' loaded, but rather to call it later when I need it. Because it was dynamically loaded, the DOM doesn't recognize the functions. How to properly call this function? Thank you

    Read the article

  • algorithm to find longest non-overlapping sequences

    - by msalvadores
    I am trying to find the best way to solve the following problem. By best way I mean less complex. As an input a list of tuples (start,length) such: [(0,5),(0,1),(1,9),(5,5),(5,7),(10,1)] Each element represets a sequence by its start and length, for example (5,7) is equivalent to the sequence (5,6,7,8,9,10,11) - a list of 7 elements starting with 5. One can assume that the tuples are sorted by the start element. The output should return a non-overlapping combination of tuples that represent the longest continuos sequences(s). This means that, a solution is a subset of ranges with no overlaps and no gaps and is the longest possible - there could be more than one though. For example for the given input the solution is: [(0,5),(5,7)] equivalent to (0,1,2,3,4,5,6,7,8,9,10,11) is it backtracking the best approach to solve this problem ? I'm interested in any different approaches that people could suggest. Also if anyone knows a formal reference of this problem or another one that is similar I'd like to get references. BTW - this is not homework. Edit Just to avoid some mistakes this is another example of expected behaviour for an input like [(0,1),(1,7),(3,20),(8,5)] the right answer is [(3,20)] equivalent to (3,4,5,..,22) with length 20. Some of the answers received would give [(0,1),(1,7),(8,5)] equivalent to (0,1,2,...,11,12) as right answer. But this last answer is not correct because is shorter than [(3,20)].

    Read the article

  • Stored Connection Strings per user

    - by pehaada
    In the past I've used a Singleton Pattern to load the connection string when the application starts via the global.asa file. I have a project now where each user has a unique connection string to the database. I would like to load this connection string once. The issue is that the singleton pattern will not work for me since each user has there own connection string. Basically the connection string is created dynamically. I do not want to store it is session. If anyway has a clever way of doing this in .NET let me know ?

    Read the article

  • Why doesn't C++ allow you to request a pointer to the most derived class?

    - by Matthew Lowe
    (This question should probably be answered with a reference to Stroustrup.) It seems extremely useful to be able to request a pointer to the most derived class, as in the following: class Base { ... }; class DerivedA { ... }; class DerivedB { ... }; class Processor { public: void Do(Base* b) {...} void Do(DerivedA* d) {...} void Do(DerivedB* d) {...} }; list<Base*> things; Processor p; for(list<Base*>::iterator i=things.begin(), e=things.end(); i!=e; ++i) { p.Do(CAST_TO_MOST_DERIVED_CLASS(*i)); } But this mechanism isn't provided in c++. Why?

    Read the article

  • Constructors for C++ objects

    - by sasquatch
    I have class Person as following : class Person { char* name; int age; }; Now I need to add two contructors. One taking no arguments, that inserts field values to dynamically allocated resources. Second taking (char*, int) arguments initialized by initialization list. Last part is to define a destructor showing information about destroying objects and deallocating dynamically allocated resources. How to perform this task ? That's what I already have : class Person { char* name; int age; public: Person(){ this->name = new *char; this->age = new int; } Person(char* c, int i){ } };

    Read the article

  • Secure to store an ID in an ASP.NET control ID?

    - by Curtis White
    I'm auto-generating a form in my ASP.NET page. This is already tested and working. I want to know if: If there are any security problems with storing the database ID as part of my controls ID? I can see think of 2 issues: the id will be visible in page source (not really important in this case), and the possibility someone could change the name of the control somehow? This second possibility is more serious. Is this a potential problem and how to void it? If there would be a better preferred way to associate a unique data with any type of control? Is it possible to store a custom item in the viewstate for the control?

    Read the article

  • Why would someone use WHERE 1=1 AND <conditions> in a SQL clause?

    - by Bogdan Maxim
    Why would someone use WHERE 1=1 AND <conditions> in a SQL clause (Either SQL obtained through concatenated strings, either view definition) I've seen somewhere that this would be used to protect against SQL Injection, but it seems very weird. If there is injection WHERE 1 = 1 AND injected OR 1=1 would have the same result as injected OR 1=1. Later edit: What about the usage in a view definition?

    Read the article

  • drawing graphs in php

    - by user434885
    i am using php to generate graphs from arrays. I wish to create multiple graphs on the same page as i need to design a summary report from answers extracted from a database. Currently i am using this code and am only able to get one single graph. what additions to the code do i need to make to get multiple graphs? <?php function draw_graph($values) { // Get the total number of columns we are going to plot $columns = count($values); // Get the height and width of the final image $width = 300; $height = 200; // Set the amount of space between each column $padding = 5; // Get the width of 1 column $column_width = $width / $columns ; // Generate the image variables $im = imagecreate($width,$height); $gray = imagecolorallocate ($im,0xcc,0xcc,0xcc); $gray_lite = imagecolorallocate ($im,0xee,0xee,0xee); $gray_dark = imagecolorallocate ($im,0x7f,0x7f,0x7f); $white = imagecolorallocate ($im,0xff,0xff,0xff); // Fill in the background of the image imagefilledrectangle($im,0,0,$width,$height,$white); $maxv = 0; // Calculate the maximum value we are going to plot for($i=0;$i<$columns;$i++)$maxv = max($values[$i],$maxv); // Now plot each column for($i=0;$i<$columns;$i++) { $column_height = ($height / 100) * (( $values[$i] / $maxv) *100); $x1 = $i*$column_width; $y1 = $height-$column_height; $x2 = (($i+1)*$column_width)-$padding; $y2 = $height; imagefilledrectangle($im,$x1,$y1,$x2,$y2,$gray_dark); } header ("Content-type: image/png"); imagepng($im); imagedestroy($im); } $values = array("23","32","35","57","12"); $values2 = array("123","232","335","157","102"); draw_graph($values2); draw_graph($values);//no output is coming draw_graph($values2);//no output is coming draw_graph($values);//no output is coming ?>

    Read the article

  • Persisting user control values afer postback in asp.net

    - by user557135
    Hi, I have a few user controls which I add to the aspx form depending on the user's choice from a combo box. I have a user control which has a textbox in it and a getValue() method that returns the value of the textbox. After user selects the related item I load the control and add to a panel using loadControl method. User enters some text. After a postback I want to keep the user control and the user input in the same state before . Hope i could be clear. Thanks in advanced

    Read the article

  • Problem FlashVars parameter asp.net

    - by sofie-vo
    Code for asp.net page <%@ Page Language="VB" AutoEventWireup="false" CodeFile="trainingupload.aspx.vb" Inherits="trainingupload" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div height> <object width="1000" height="800"> <param name="movie" value="player.swf" /> <param name="FlashVars" value='userid=<%=String.Format(getuser())%>" '/> <embed src="bin-release/trainingscentrum.swf" FlashVars='userid=<%=String.Format(getuser())%>" ' width="1500" height="800" /> </embed> </object> </div> </form> </body> </html> Code behind Public Function getuser() As Guid Dim user As MembershipUser = Membership.GetUser() Dim userid As Guid = (CType(user.ProviderUserKey, Guid)) Return userid End Function In the code above I use an function to return the userid. When I replace <%=String.Format(getuser())% with an actual userid, I get the value in my flex application. But this code returns nothing. What am I doing wrong?

    Read the article

  • Using Variables for Class Names in Python?

    - by Sam McAfee
    I want to know how to use variables for objects and function names in Python. In PHP, you can do this: $className = "MyClass"; $newObject = new $className(); How do you do this sort of thing in Python? Or, am I totally not appreciating some fundamental difference with Python, and if so, what is it?

    Read the article

  • how to allocate memory for struct itself, and its members

    - by Jack
    I have this struct: struct foo { char *a; char *b; char *c; char *d; }; it's possible allocate space for struct itself and its members instead of e.g, struct foo f; f.a = malloc(); f.b = malloc(); f.c = malloc(); f.d = malloc(); strcpy(f.a, "a"); strcpy(f.b, "b"); //.. something like this(of couse that it doesn't works): struct foo f = malloc(sizeof(struct f)); strpcy(f.a, "a"); //etc

    Read the article

  • Does video tag (HTML 5) injection via JavaScript work in any browsers?

    - by JoshNaro
    I'm trying to dynamically spawn a video element on a page using JavaScript. JavaScript <script type="text/javascript"> $(document).ready(function() { var video = $(document.createElement('video')) .attr('id', 'VideoElement') .attr('controls', 'controls') .attr('src', 'videopath.mp4') // Changed 'href' attribute to 'src' .css({ width: 640, height: 360 }); $('#VideoContainer').append(video); }); HTML <body> <div id="VideoContainer"></div> </body> In Firefox I get the video harness, but the actual video doesn't load. In IE8 the video harness doesn't even appear. Is HTML 5 just not supported enough to accomplish this yet? Edit: Got this to work with Artiom's fix. Looks like this works fine with Chrome and Safari. I'm using a codec Firefox doesn't support, so it doesn't work there; although I suspect it will work with a supported codec. IE8 sure enough doesn't work (high five IE).

    Read the article

  • Why do I have to explicitly cast sometimes for varargs?

    - by Daniel Lew
    I've got a Class that uses reflection a lot, so I wrote a method to help out: private <T> T callMethod(String methodName, Class[] parameterTypes, Object[] args) { try { Class c = mVar.getClass(); Method m = c.getMethod(methodName, (Class[]) parameterTypes); return (T) m.invoke(mVar, args); } // Insert exception catching here [...] } This worked well for any method that had parameters, however I had to explicitly cast parameterTypes to Class[] in order for this to work for methods with no parameters (e.g., callMethod('funName', null, null);). I've been trying to figure out why this is the case. It seems to me that if parameterTypes, when null, had no concept of what type it is (Class[]), then I'd need to cast it for getMethod(). But if that's the case, why is getMethod() able to tell the difference between null, and (Class[]) null when the method is invoked?

    Read the article

  • can i changed for loop index variable inside the loop in Matlab???

    - by shawana
    hi every one. i need to change my loop variable inside the iterationa as ihave to acces array elements in the loop which is changing w.r.t size inside the loop. ashort piece of code is that: que=[]; que=[2,3,4]; global len; len=size(que,2) x=4; for i=1:len if x<=10 que(x)= 5; len=size(que,2) x=x+1; end end que array should print like: 2 3 4 5 5 5 5 5 5 5 but it is printed in such a way: 2 3 4 5 5 5. how shuould it be accomplished in matlab? in visual c++ it happen correctly and print whole array of 10 elements which increases at run time plz reply me if have any ideaabout this as i m new into matlab

    Read the article

  • how to cast an array of char into a single integer number?

    - by SepiDev
    Hi guys, i'm trying to read contents of PNG file. As you may know, all data is written in a 4-byte manner in png files, both text and numbers. so if we have number 35234 it is save in this way: [1000][1001][1010][0010]. but sometimes numbers are shorter, so the first bytes are zero, and when I read the array and cast it from char* to integer I get wrong number. for example [0000] [0000] [0001] [1011] sometimes numbers are misinterpreted as negative numbers and simetimes as zero! let me give you an intuitive example: char s_num[4] = {120, 80, 40, 1}; int t_num = 0; t_num = int(s_num); => 3215279148 ?????? the result should be 241 but the output is 3215279148? I wish I could explain my problem well! how can i cast such arrays into a single integer value?

    Read the article

  • ASP.NET DynamicData: Whats happening during an update?

    - by Jens A.
    I am using ASP.NET DynamicData (based on LINQ to SQL) on my site for basic scaffolding. On one table I have added additional properties, that are not stored in the table, but are retrieved from somewhere else. (Profile information for a user account, in this case). They are displayed just fine, but when editing these values and pressing "Update", they are not changed. Here's what the properties look like, the table is the standard aspnet_Users table: public String Address { get { UserProfile profile = UserProfile.GetUserProfile(UserName); return profile.Address; } set { UserProfile profile = UserProfile.GetUserProfile(UserName); profile.Address = value; profile.Save(); } } When I fired up the debugger, I've noticed that for each update the set accessor is called three times. Once with the new value, but on a newly created instance of user, then once with the old value, again on an new instance, and finally with the old value on the existing instance. Wondering a bit, I checked with the properties created by the designer, and they, too, are called three times in (almost) the same fashion. The only difference is, that the last call contains the new value for the property. I am a bit stumped here. Why three times, and why are my new properties behaving differently? I'd be grateful for any help on that matter! =)

    Read the article

  • Dynamically assembling SQL queries in Java

    - by kd
    What is the best way to assemble an SQL query with join conditions dynamically? I don't want to hard code the query for each different condition on a webpage or a set of webpages. Is it even feasible? I got as far as being able to assemble simple queries but i got stumped when i needed to insert join conditions, i.e. how to figure out dependencies for joins etc.

    Read the article

  • Minimize the sequence by putting appropriate operations ' DP'

    - by Vikas
    Given a sequence,say, 222 We have to put a '+' or '* ' between each adjacent pair. '* ' has higher precedence over '+' We have to o/p the string whose evaluation leads to minimum value. O/p must be lexicographically smallest if there are more than one. inp:222 o/p: 2*2+2 Explaination: 2+2+2=6 2+2*2=6 2*2+2=6 of this 3rd is lexicographically smallest. I was wondering how to construct a DP solution for this.

    Read the article

  • Resizing iframe height using javascript issue

    - by Camran
    I have an iframe which content is a php-file, and that php-file displays some mysql records. The more records, the larger the iframe height should get, otherwise it wont show all of the information in the iframe. Here is a code I have for dynamically setting the iframe height, from the iframes content (the php file): var x = document.body.scrollHeight; x = x + 20 + 'px'; window.parent.document.getElementById("iframe001").style.height=x; iframe001 is the iframe I am referring to above. I am adding 20px of height extra because of borders etc... Now, sometimes this resizing works, sometimes it doesn't. Does anybody know why it works sometimes. If I alert the 'x' variable, it shows different values sometimes, but most times it works. Any other ways you know of setting the iframes height from the content of the iframe? Thanks

    Read the article

  • C++ new memory allocation fragmentation

    - by tamulj
    I was trying to look at the behavior of the new allocator and why it doesn't place data contiguously. My code: struct ci { char c; int i; } template <typename T> void memTest() { T * pLast = new T(); for(int i = 0; i < 20; ++i) { T * pNew = new T(); cout << (pNew - pLast) << " "; pLast = pNew; } } So I ran this with char, int, ci. Most allocations were a fixed length from the last, sometimes there were odd jumps from one available block to another. sizeof(char) : 1 Average Jump: 64 bytes sizeof(int): 4 Average Jump: 16 sizeof(ci): 8 (int has to be placed on a 4 byte align) Average Jump: 9 Can anyone explain why the allocator is fragmenting memory like this? Also why is the jump for char so much larger then ints and a structure that contains both an int and char.

    Read the article

< Previous Page | 96 97 98 99 100 101 102 103 104 105 106 107  | Next Page >