Casting Request.Forms To String?
Mar 29, 2010
I'm calling a method like this:
DataTable dtModifiedData = detailsGrid.GenerateRowColumnDataTable(Request.Form)
The GenerateRowColumnDataTable method retrieves all form variables with <input> tags. My problem is that my columns are named in a strange format like this:
#X#_G1_NAME_1 so when I look at what's being rendered I see %23X%23_G1_NAME_1 so I thought I could use Server.URLEncode() around Request.Form but I'm getting an errot that it can't be converted to a string. What would you do in this case?
View 7 Replies
Similar Messages:
Oct 15, 2010
Im dynamically generating an HTML Select Box, lets call it myselect. Im creating this select box based on some database values Im generating an HTML Select Box.. almost like a string that Im just spitting out to the page. So it's never a control in the codebehind, just part of a string thats rendered as HTML by the browser. If I submit my form, and in my codebehind I perform:
Dim myVal as String = Request.Form("myselect")
That code will give me the VALUE of the myselect select box. How can I refer to this control to cast it as a System.Web.UI.HtmlControls.HtmlSelect control? Request.Form seems to give me the value, but I want to reference the object itself..
View 3 Replies
Jul 19, 2010
I´m trying to use session to store a value (id). The problem is that I have to store it as a string. When trying to use the instance of the id I get the error:
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Line 156:
Line 157: Nemanet_Navigation newFile = new Nemanet_Navigation();
Line 158: newFile.Nav_pID = (Guid)Session["id"];
Line 159:
Line 160:
This is where I get the id and that seems to work fine. Session["id"] gets the value.
[code].....
View 3 Replies
Mar 31, 2011
I have a scenario where i have to pass the array list to the WebService.
WebService:
[WebMethod]
public void GetCommission(List<BOLibrary.Flight.DTContract> Loc)
{
CommissionManager test = new CommissionManager();
}
Client:
List<BOLibrary.Flight.DTContract> BoList = new List<BOLibrary.Flight.DTContract>();
BOLibrary.Flight.DTContract dtConboj = new BOLibrary.Flight.DTContract();
dtConboj.ValidatingCarrier = "AA";
DTContract[] loc1 = BoList .ToArray();
service.GetCommission(loc1);
when i am trying to do this i am getting the exception that cannot convert the BOLibrary.Flight.DTContract to DTContract This is because when webservice create proxey consider Type(DTContract) not namespace(BOLibrary.Flight.DTContract)and i have to pass the list or arraylist of BOLibrary.Flight.DTContract Type.
View 1 Replies
Jun 25, 2010
I am using the following code to convert any valid object, to a date time:
[Code]....
When i call this mehod from my web pages, using a blank("") value in TextBox.Text property as a parameter, the method is throwing an FormatException exception.
[Code]....
Ironically, the same method does not throw any exception with the same input when tried in a different machine.
Are there any regional setting that need to be modified in .NET 2.0 for this to work ?
P.S:
The method also works when called using a string variable, like
[Code]....
[Code]....
View 4 Replies
Jun 16, 2015
Im getting this error while developing login page "The length of the query string for this request exceeds the configured maxQueryStringLength value".
View 1 Replies
Sep 22, 2010
I have a requirement to build a simple ASP.NET web page which sends some parameters to a web service, and then displays the string which was returned. I'm a complete .NET newby and the only examples I can find seem really really complex. I just need something mega simple, but which an handle parameters being sent to the web service. Can anyone point me in the direction of a simple bit of C# which will do this with no frills or fuss?
View 1 Replies
Sep 16, 2010
So I'm writing an MVC application, and have a JsonResult post back to obtain some item information for scanned items on a warehouse application I am writing. I'm trying to obtain a URL query string value though, and cannot seem to obtain one via the normal 'Request.QueryString['variable']' way... Is there a way to do this? I also thought about just passing the parameter into my post, but I already have a single value on my jquery post, and I am unsure if I can tack on more values to this.
View 7 Replies
Mar 9, 2011
i try casting the gridview datasource to datatable using the following code but the datatable always nothing.
Dim DT As New DataTable
DT = DirectCast(gv.DataSource, DataTable)
the gridview is bound using dataset at code behind without using sqldatasource.
i m trying to filter the gridview without geting the data from database, is there is another way to do this?
View 4 Replies
Feb 18, 2010
Okay, so I have a Generic IList of custom objects that I want to use as a datasource for a repeater.
[Code]....
In the WebForm inside the repeater, I place this code:
[Code]....
when I try to run it, I get the error "Unable to cast object of type 'System.Collections.Generic.List`1[MyCustomObject]' to type'MyCustomObject'. ". Which makes sense, really.
What's the best way round this? Is there any way I can get the direct cast working? I'm loath to have to create a custom list item that implements IBinding or something and bind that directly, as that'll mean a lot of legacy changes which may create further bugs. Or is there a better way?
View 3 Replies
Oct 25, 2010
System.InvalidCastException was unhandled by user code
View 4 Replies
Jul 22, 2010
I use the DetailsView control to display selected employee's data for HR. The list of data elements has gotten pretty long so I thought I'd put some tables & panels inside the ItemTemplate and EditTemplate. Testing with NO code behind in effect works perfectly on display & update. Now I need to manipulate some stuff in the code behind which requires me to cast the controls I'm after. However old cast code doesn't work (it says the row index doesn't exist).
First is a clip of the DetailsView which gives me 3 nice columns.
[Code]....
View 2 Replies
Apr 20, 2010
When making a call to a SOAP web service how does one go about adding a user agent string to the request from a SOAP client?
View 1 Replies
Jan 6, 2010
I would like to create the XML string on the the aspx page and then submit this request using the YUI ajax request to another aspx page for the processiong. So
1. is this possible by setting some of the ajax requests configurations like we do on ajax response ?
2. How it can be done ?
View 2 Replies
Oct 6, 2010
When user requests http://localhost/WebApp1/Default.aspx, txtApplicationPath.Text should be assigned "/WebApp1", while txtAbsolutePath.Text should be assigned "http://localhost/WebApp1/Default.aspx", but instead both textboxes display empty strings.
[code]...
View 1 Replies
Apr 6, 2010
I want to dynamically populate a link with the URI of the current request, but set one specific query string parameter. All other querystring paramaters (if there are any) should be left untouched. Eg, imagine I want to build a link back to the current page, but with the querystring parameter "valueOfInterest" always set to be "wibble" (I'm doing this from the code-behind of an aspx page, .Net 3.5 in C# FWIW).Eg, a request for either of these two:
/somepage.aspx
/somepage.aspx?valueOfInterest=sausages
would become:
/somepage.aspx?valueOfInterest=wibble
And most importantly (perhaps) a request for:
/somepage.aspx?boring=something
/somepage.aspx?boring=something&valueOfInterest=sausages
would preserve the boring params to become:
/somepage.aspx?boring=something&valueOfInterest=wibble
Caveats: I'd like to avoid string manipulation if there's something more elegant in asp.net that is more robust. However if there isn't something more elegant, so be it. I've done (a little) homework: I found a blog post which suggested copying the request into a local HttpRequest object, but that still has a read-only collection for the querystring params. I've also had a look at using a URI object, but that doesn't seem to have a querystring
View 3 Replies
May 20, 2010
Whats the best method of casting. I've been using syntax like this:
Button btnSubmit = (Button)item.FindControl("Btn_Submit")
but is this better or just different:
Button btnSubmit = item.FindControl("Btn_Submit") as Button
View 3 Replies
Feb 17, 2011
I'm using linq to sql to populate a list of objects. One of the fields I'm interested in is stored as a tinyint. How should I declare this property type in my object definition? As a Short? Byte? Int16?
View 4 Replies
Nov 7, 2010
I have this problem where I am passing NVARCHAR parameter to a stored procedure, and the field type in the table for that parameter is INT.
I am doing that because I am using IN function, and for example if I want to send multiple parameters, that is the only possible way to do through .NET. Or not? The SP doesn't get executed because of the wrong type, and I am trying to cast the value, but I get an error. Here is how I am trying:
Example:
@Parameter nvarchar OrderStatusID = ('30, 40')
(o.OrderStatusID IN (CAST(@OrderStatusID as int)) OR @OrderStatusID IS NULL)
Is there a way to cast each value separately, or what will be the best way to cast whole value as INT.
View 2 Replies
Jun 16, 2010
I am pulling a 'long' value from Session, using a generic property, and it is crashing. so I have:
public static T Get<T>(string key)
{
if(...)
return (T)System.Web.HttpContext.Current.Session[key];
...
}
When debugging, the value is 4, and it crashes.
View 3 Replies
Apr 21, 2010
i have a xml file and i am retrieving its value using Linq to xml and assigning it to ViewData.
[code]...
but foreach (var item in ViewData["Persons"] is giving type casting error..what should be the exact type csting so that i can retrive values in the format item.Fname.
View 3 Replies
Jul 28, 2010
I have a bit column that is saved as 1 or 0 in the database. I want to check the value in the table and then do an if statement depending if its 1 or 0. How can I convert it to an int?
i had
lockValue = (int)sqlCommand1.ExecuteScalar();
I want to assign it to the lockValue int variable. I then want to go on and check
if (lockValue == 1) {
// stuff
}
View 1 Replies
Feb 19, 2013
Why it's not possible to cast a SiteMapNodeCollection (eg. SiteMap.CurrentNode.ChildNodes) to an IEnumerable<SiteMapNode>? I was wanting to do some filtering of the collection via LINQ, but this might not be possible?
The MSDN page says it implements IList, ICollection, and IEnumerable, so I don't see what the problem is.
View 4 Replies
Sep 23, 2010
I have a situation where I'm iterating through all the controls on a form, specifically looking out for any of these three types of controls: Labels, TextBoxes, CheckBoxes
I can, of course, get the type of the control and then use a Switch-Case construct to cast labels as Labels, textboxes as TextBoxes, and checkboxes as CheckBoxes.
But I'm wondering if there's a way to do something with one or two lines of code to gain access to the Text property of each of these controls?
View 4 Replies
Nov 10, 2010
I am passed an IQueryable that might be already be ordered and that therefore might be an OrderedQueryable. I need to apply it a new ordering via reflection, anb before choosing if calling either OrderBy or ThenBy I need to now if the Queryable is IOrderedQueryable.
Now comes the problem! To see if may variable say query is an IOrderedQueryable I do:
IOrderedQueryable orderedQuery = query as IOrderedQueryable;
One might expect orderedQuery be null in case query is not an IOrderedQueryable ! INSTEAD orderedQuery is NEVER NULL. It takes the value of a different type!
I understand that this might happen because of deferred execution...
I tried also: query is IOrderedQueryable and it is always true!
How can I verify if query is actually an IOrderedQueryable before getting an exception when calling ThenBy?
The IQueryable comes from the Entity Framework 4.0
I am able to see it if I access the object that is behind the interface, but this way I would loose the benefif of using interface, and my class might not work with a different implementation of the IQueryable.
View 2 Replies