C# - The IndexOf() Method Returns -1 All The Time
Aug 26, 2010
i have two data tables with the same structure
the first one has one row of the second one
the second one has set of rows
what i want is to get the row which comes next to the row of the first data table in the second data table.
the first data table his name is :: temp
the second data table his name is :: dt
i do the following:
DataTable temp = new DataTable();
temp = dt.Clone();
DataColumn[] keyColumn = new DataColumn[1];
keyColumn[0] = temp.Columns["photoId"];
temp.PrimaryKey = keyColumn;
temp = (DataTable)(Session["currentImage"]);
DataRow[] drr = new DataRow[1];
index = dt.Rows.IndexOf(temp.Rows[0]);
but the index always comes with one value = -1
although the temp.rows[0] its contents changed all the time
when i write dt.Rows.IndexOf(dt.Rows[1]) for examble i get 1
but this is not what i want to do ,, what i want to do exactly is to get the datarow next to the datarow of the first dataTable in the second dataTable
View 2 Replies
Similar Messages:
May 12, 2010
Here is a bunch of code from a certain site;
Code:
<script type="text/javascript">
function ShowTime() {
[Code]....
the ShowTime function returns server time or client's time.However, I know that javascript executes in the client side.
View 3 Replies
Jan 16, 2011
I've an EntityCollection< T > which contains an element but the Contains method returns false.
I've overriden T's 'Equals' method but the 'Contains' method does not call it (while it's said so in documentation).
When I do foreach (T x in coll), x.Equals(element) returns true.
code:
contains(object entCol, object val)
{
var coll = (ICollection<GraphicSockets>)entCol;
var socket = val as GraphicSockets;
foreach (GraphicSockets sock in coll)
socket.Equals(sock); //true for first element, GraphicSocket's Equals function called
coll.Contains(socket);//false, Equals function not called}
the code i'd actually like to use is
private static bool contains(object entCol, object val)
{
Type entColType = typeof(EntityCollection<>).MakeGenericType(val.GetType());
MethodInfo contains = entColType.GetMethod("Contains");
return (bool)contains.Invoke(entCol, new object[] { val });
}
this worked once but stopped when i started using wcf, i wonder how this contains method works.....
View 2 Replies
Sep 1, 2010
How can I set the value of WizardStep.IndexOf() programatically? eg.
[Code]....
View 5 Replies
Feb 19, 2010
had used ajax.method in my project & its working fine, but now Every Ajax.Method returns null now,
View 1 Replies
Feb 19, 2010
I a method that generates a PDF and the method returns a byte value, but after response.end statement, the shows an error that the "File does not begin with '%PDF-' here is the code:
[Code]....
[Code]....
View 2 Replies
Mar 11, 2010
I have a ListView control and under ItemTemplate I have following code:
Code:
<asp:Label ID="Label1" runat="server" Text='<% #MatchCategory(dtCategories.Rows[i]["ID"].ToString().Trim(), Eval("CategoryID").ToString()) %>'></asp:Label>
The MatchCategory method just checks if two values are equal and return true or false. Just below this code I am separately printing dtCategories.Rows[i]["ID"].ToString().Trim() and Eval("CategoryID")
acan see matching values but MatchCategory method always returns false.
View 5 Replies
Apr 17, 2010
I'd like to be able to determine what class will be called given an URL. For instance, I have a page /First.aspx that has a hyperlink to /Second.aspx In the code behind for First.aspx.cs, I'd like to be able to determine what class will execute if someone clicks on the hyperlink that points to /Second.aspx.
EDIT: One of the reponders asked me to outline the problem I'm trying to address. Here it is: The codebase I inherited has a subclass the System.Web.UI.Page that has a public Authorized method that returns a boolean. The Authorized method checks the parameters passed via the query string against the authenticated user, and determines whether that user should be allowed to call that page with the given parameters.
Elsewhere in the site I have hyperlinks that reference those protected pages. In some instances those links are displayed to users who are not authorized to navigate to that page. They can click the link, however they get an error. In other instances, prior developers when through the trouble of inserting logic that hides the hyperlink for those unauthorized users, but the authorization logic is duplicated (In the page itself, and in the linking page). What I would like to do is create a subclass of the hyperlink class, and have the subclass inspect the NavigateUrl, determine the destination page class, and call the Authorized method of that class to determine if the user is authorized to call that page. If the user is not authorize, the link will automatically hide itself.
View 2 Replies
Feb 15, 2011
[Code]....
If I use $get, it does work as the expected functionality for $get. It is only $find that does not work.
Can anyone explain the problem?
View 5 Replies
Jan 29, 2010
I have developed a web application 3 months ago to show facebook users by searching username. To access facebook, I have downloaded facebook dll and got application key, and secret key from facebook. My web application was working fine and displaying records from facebook. yesterday onwards, my application is not working fine. I could not get response when I search by name. I have tested the fql in the facebook testAPI tool online. That time i can get response. but the same fql i used in my appliation but it could not get response from facebook when I search by name. If i search by uid i can get response from facebook. here is my code.
facebook.Components.FacebookService fb = new FacebookService();
fb.ApplicationKey = "bfeefa69afdfe81975f0d6136ace3009";
fb.Secret = "9b672d682e1d8befd06382953fc2615b";
fb.IsDesktopApplication = false;
//the below fql gives response as xml.
//select name, profile_url from user where uid = '1730923544' -I can get response for this fql.
//the below fql does not give response as xml. But it gives empty string.
//the below fql does gives us response as xml when i try in facebook testAPI.
//select name, profile_url from user where name = 'Suresh Rajan' -I couldn't get response for this fql.
string s = fb.fql.query("select name, pic_square, profile_url from user where name = 'Suresh Rajan'");
if (String.IsNullOrEmpty(str1))
Response.Write("Empty Response");
else
Response.Write(str1 + " ");
how to search by name in facebook fql.
View 1 Replies
Mar 31, 2011
I have a simple page containing a GridView control that generates thead and tbody tags after rendering. In my jQuery script, I have a line that reads this way:
$('#GridView1
thead').eq(0).html()
When the page loads for the first time, this script returns an objects and works well. But when I click a button and cause a postback, it returns null. By the way, the button changes the number of the rows returned from the data source (based on the value of a textbox) and updates the grid.
View 1 Replies
Apr 27, 2016
This is the query I am running in DB:
select UM.USER_NAME, RM.ROLE_ID, RM.ROLE_NAME
FROM [MICommonDB].[dbo].[ROLE_USER_MAPPING] as RUM
join [MICommonDB].[dbo].[ROLE_MASTER] as RM ON RM.ROLE_ID=RUM.ROLE_ID
join [MICommonDB].[dbo].[USER_MASTER] UM ON UM.USER_ID = RUM.USER_ID
where UM.USER_NAME='useruser'
which is giving me proper result(i.e., 2 records) when running in SQL server.
Now I have created below method in a class with same query (I am calling this method inside Controller):
public IEnumerable<RoleUserDO> getRoleNameByUserName(string userName)
{
IEnumerable<RoleUserDO> strResult = null;
strResult = (from RUM in oDBContext.ROLE_USER_MAPPING
[CODE]..
but it returns only 1 record instead of 2 records(when compared with DB query)
View 1 Replies
Jan 15, 2010
Iam confronted with a really weird issue the like of which ive never seen before. I recently developed a web application using ASP.net and launched it for my company, during the bug testing stages everything seemed fine, but once it was actually in production i started getting these weird errors that all stem from it not retrieving the correct rows.
The issue is this, sometimes the queries sent to the back end only return a partial amount of the rows actualyl requested, so if a user has a page loaded thats suppose to return X number of rows, they can sometimes get X - Y number of rows, and upon refreshing the page they get X - Z number of rows, and refreshing the same exact page again they might get X number of rows they were initially suppose to see. I've never seen anything like this before so Iam stumped.
I consulted some of the old developers in the company I used to work for, for assistance but when explaining and showing the problem they too were very confused with the issue.
View 10 Replies
Jul 1, 2010
I added a new table to my type dataset. When the code tries to execute the new row on that table I get the error message.
(if you can't see the error. "MissingMethodException was caught" "Method not found: 'MyTableDataTable MyNamespace.get_SSCase().")
I've tried the wizard and also click and drag the table from solution explorer to the xsd file. The other tables work, just this one table won't work. What should I check?
View 1 Replies
Nov 29, 2013
I have detailsview control with bound fields...some usingĀ Templatefields. I am trying to access values in those fields but i get nulls....i really dont know why..I am proving all my code....
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Projects.aspx.vb" Inherits="Projects" %>
<!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 id="Head1" runat="server">
<title>Projects Statuses</title>
[code]....
I guess something might be getting messy with the mode changing event... a postback? But if i remove the databinding code, i get an error! why find control returns null??
View 1 Replies
Aug 17, 2010
I have built a WCF Service that is being consumed by a Silverlight app. At first I created one method that was very simple:
public String SfTest()
{
return "SF Test";
}
No poblem. My silverlight app references my service and displays "SF Test" in a textbox. Now I add a method to my wcf service like this:
public List<String> GetTest()
{
List<String> list = new List<string>();
String a = "a";
list.Add(a);
String b = "b";
list.Add(b);
return list;
}
I update the reference to the service in my Silverlight app and the using statement in my xaml cs page throws an error like the service doesn't even exist although it is there. I am assuming the problem has to do with datatypes or serialization or something like that but it is driving me up the wall. Why can't I consume a simple generic list in my Silverlight app through the WCF service.
View 1 Replies
Dec 13, 2010
I would like to check whether a folder exists or not if not create. I'm sure this folder exists, but for some reason I get "false" when I check with "Exists" method.
The only reason I think could be because of the W: drive? I moved this application to production site and even there it returns false.
while I'm type in Windows explorer on my localhost and on the server "W:/Webs/ASPPages/cropper/uploads" it opens this folder. So my localhost and IIS server has W: mapping.
for test I tried to create the folder then it says can't find the path...
userFolderName = @"W:/Webs/ASPPages/cropper/uploads"
//I also tried @"W:WebsASPPagescropperuploads"
//I also tried @"W:WebsASPPagescropperuploads"
//I also tried "W:\Webs\ASPPages\cropper\uploads"
DirectoryInfo dirInfo = new DirectoryInfo(userFolderName);........
View 3 Replies
May 9, 2010
protected void Button19_Click(object sender, EventArgs e)
{
SqlDataSource conn = new SqlDataSource();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["Database2ConnectionString1"].ToString();
conn.SelectCommandType = SqlDataSourceCommandType.Text;
conn.SelectCommand = "SELECT FROM table1 (a, b)VALUES(@a,@b)";
conn.SelectParameters.Add("a",TextBox1.Text);
conn.SelectParameters.Add("b", TextBox2.Text);
int rowsAffected = 0;
try
{
rowsAffected = conn.Selectt();
}
catch (Exception)
{
Label1.Text = "Error";
}
finally {
conn = null;
}
if (rowsAffected != 0)
{
Label1.Text = "Data saved";
}
}
well it returns error no overloading method for select (P.S. same code work fine for insert)
View 5 Replies
Mar 16, 2011
I'm having trouble with something that is (or should be) fairly straight-forward.
I have a recursive method that traverses an XML file, writing out the element tag names and values.
This is a snippet from the XML file:
[code]
<root>
<all_companies>
<company_group company_group_ID_attr="1">
<company_group_name>Cleaning</company_group_name>
<company_group_ID>1</company_group_ID>
<company company_ID_attr="2">
<name>Bloomburg</name>
<company_ID>2</company_ID>
<Address>blah blah blah</Address>
<employee_refs>
<employee_ref>4</employee_ref>
</employee_refs>
</company>
<company company_ID_attr="4">
<name>Morris</name>
<company_ID>4</company_ID>
<Address>blah blah blah</Address>
<employee_refs>
<employee_ref>3</employee_ref>
<employee_ref>1</employee_ref>
</employee_refs>
</company>
<company company_ID_attr="7">
<name>Ajax</name>
<company_ID>7</company_ID>
<Address>blah blah blah</Address>
<employee_refs>
<employee_ref>4</employee_ref>
<employee_ref>2</employee_ref>
</employee_refs>
</company>
</company_group>
</all_companies>
</root>
[/code]
I use the following XPath expression to access the first <company group> tag:
"root[1]/all_companies[1]/company_group[1]"
On the first call to the recursive method ("swrite_for_select_certain_stuff"),I see with the debugger that I reach the <company_group_name> tag. A recursive call at that point takes me to the text node within the tag ("Cleaning"), but it is a text type node (not an element), so it returns without writing anything to the output stream.
On return from that second call, things go wrong. The Iterator within the while loop returns false for the MoveNext method, when it should have moved to the <company_group_ID> tag (or so I think it should).
Am I missing something here?
OS is Win XP, and .NET is version 4.0.
My code is as follows:
[Code]....
View 1 Replies
Sep 29, 2010
I have the following code:
[WebMethod]
[SoapHeader("_webServiceAuth")]
public User GetUser(string username){
try
{
this._validationMethods.Validate(_webServiceAuth);
User user = new User(username);
[code]...
View 1 Replies
Mar 24, 2011
I have a JQuery Method. When I click on button "btnSelectDisclosure", a popup appears but only once. Not for next time.
[code]...
View 1 Replies
Jul 14, 2010
I ve just added quartz.net dll to my bin and started my example... How to call a c# method using quartz.net based on time?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Quartz;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(SendMail())
Response.write("Mail Sent Successfully");
}
public bool SendMail()
{
try
{
MailMessage mail = new MailMessage();
mail.To = "test@[URL]";
mail.From = "sample@[URL]";
mail.Subject = "Hai Test Web Mail";
mail.BodyFormat = MailFormat.Html;
mail.Body = "Hai Test Web Service";
SmtpMail.SmtpServer = [URL];
mail.Fields.Clear();
mail.Fields.Add([URL], "1");
mail.Fields.Add([URL], "redwolf@[URL]);
mail.Fields.Add([URL], "************");
mail.Fields.Add([URL], "465");
mail.Fields.Add([URL], "true");
SmtpMail.Send(mail);
return (true);
}
catch (Exception err)
{
throw err;
}
}
}
Here i am just sending a mail on page load. How to call SendMail() once in a day at a given time (say 6.00 AM) using quartz.net. I dont know how to get started? Should i configure it in my global.asax file.
View 2 Replies
Nov 19, 2010
asp.net 3.5...
I changed a method from public static void LogError(Exception exception) to public static Guid LogError(Exception exception) and once deployed the app throws the error
Method not found: 'System.Guid DefaultTechnologies.Portal.BusinessLogic.Common.LogError(System.Exception)'.
When deployed I sent all non-third party *.dll to be dropped into the bin folder. Runs fine from my machine :) but fails like crap everywhere else.
View 3 Replies
Nov 24, 2010
I have a complex ASP.NET application and it's running since 2009.I need to monitor it's performance and determine which methods in which layers are time or resource consuming. Then I can optimize methods.
Right now, I'm using SQL Profiler to check the queries and I tune the database step by step. I want to do the same for other layers (UI, Service, and Repository).I've used Postsharp and Enterprise Library Policy Injection Application Block.
I've implemented some attributes and add them to some classes which get BeforeMethodEntry and AfterMethodEntry (AOP model) automatically. Therefore, I can get the execution time of each method. It also handles exception log and page view log.
But, I think there may be another implemented/standard solution to monitor the running application.
PS: I've implemented some other solution like implementing ExceptionHttpModule and PageViewHttpModule which don't need any Third Party libraries. It doesn't meet my requirements.
*In a simple words, I want to log and monitor layer's activities (specially mehod execution duration). *
View 2 Replies
Sep 30, 2010
I would like to create a progress bar with real time updates on the different method calls that happen on a button click in asp.net 1.1. I have seen some examples but nothing that provides updates on the progress bar while the server side operation executes.
View 1 Replies