Forms Data Controls :: Specifying Integer When Returned From DB?
Feb 25, 2011
I'm trying to use a variable returned from the database as an integer. My thought is to use a Link button and when my user clicks it, it should open a new window. However, its giving me an error stating the value is in the wrong format. Here is my link button code.
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Bind("Name") %>' PostBackUrl='profiles/profile.aspx?id=<%# Bind("ID") %>'></asp:LinkButton>
</ItemTemplate>
The error I get when I click is:
System.FormatException was unhandled by user code
Message=Input string was not in a correct format.
Source=mscorlib
StackTrace:
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at System.Convert.ToInt32(String value)
at Training_profiles_profile.Page_Load(Object sender, EventArgs e) in d:projectsDIETMIWEB_svn-trunkDIETMIWEB_svnTrainingprofilesprofile.aspx.cs:line 25
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
View 1 Replies
Similar Messages:
Jan 13, 2011
I am having dataset and I want to validate particular column for Integer(Numeric) value.
e.g.
ErrorRows = dt.Select("LEN(Year) <> 4 ")
Above I have to validate Year column for Numeric value otherwise it should give me erroneous records which have data other than numeric.
View 2 Replies
Apr 27, 2010
I happen to have used datasets and hence data tables in most of data access approaches.
This time arround i want to exctract the integer value and use it in the if statement for testing.
I however face a problem in the fact that though i can select the particular cell in a table i still get a table adapter which is not what i need and is not covertible to int value.
See the code below:
[code]....
How can I extra this particular xFiled value and return and integer value rather than a data table?
View 5 Replies
Feb 23, 2011
I am trying to do some calculation in the page behind .cs like this:
int points = Convert.ToInt32(customer.TotalPoints.ToString()) * Convert.ToInt32(5);
lblBalance.Text = points.ToString();
In the gridview it is like this:
[Code]....
I have Lable with ID "lblBalance" but still I keep on getting error that it does not exists - how to fix this ?
View 13 Replies
Dec 23, 2010
I have a GridView that records can be added to.There are only 2 fields in the table that the records come from which are date field and an integer field.The date field is fine "as is".The problem is that you can't format the integer field.I have tried every way that I can think off.The last 2 ways that I have tried have used String.Format because I am using EVal and with Eval you can supply anoptional second parameter to specify a format for the returned string.I have tried in both html and code behind , html gives an error message but the code behind (code behindthe RowDataBound method) doesn't give an error message:In the html looks like:
<ItemTemplate>
<%# Eval(("inFrmDate").ToString(), String.Format("{G}")) %>
</ItemTemplate>
[code]...
View 5 Replies
Feb 11, 2010
I am trying to reconstruct a date/time period from five data elements Year, StartMonth, StartDate, EndMonth, EndDate If the event starts on June 5 and ends on June 6, 2010 - The label would read June 5 thru 6, 2010. If the event starts on June 30 and ends on July 2, 2010 - the Label would read June 30 thru July 2, 2010. and if the event starts on June 5 and ends on June 5, 2010 - The label would read June 5, 2010. I've tried a few variations without success. This one comes closest to what I'm aiming for.
[Code]....
View 3 Replies
Jan 31, 2011
i am using visual studio 2008 vb. i have a dropdownlist in my detailsview populated with product id. when i select an id, the product name will appear on a label. however, when i change the product id in the dropdownlist, an error occur "Conversion from string "ProductName" to type 'Integer' is not valid." Here's the code file.
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim lbl As Label = DetailsViewOrderDetails.FindControl("Label4")
Dim ddl As DropDownList = DetailsViewOrderDetails.FindControl("DropDownList1")
lbl.Text = ddl.SelectedValue("ProductName").ToString()
End Sub
View 4 Replies
Jan 15, 2010
I have the following code reading in my xml file and sorting it by ID:
Dim ds As New DataSet
ds.ReadXml(Server.MapPath("/posts.xml"))
Dim dv As New DataView(ds.Tables(0))
dv.Sort = "id desc"
The only problem is that it isn't sorting it numerically (it's sorting it alphabetically 1, 10, 11, 2, 24, 3, 4...). It appears as though I have to convert that column into integers, but I haven't been able to figure out an efficient way to do that.
im ds As New DataSet
ds.ReadXml(Server.MapPath("/App_Data/posts.xml"))
'ds.Tables(0).Columns(0).DataType = TypeOf(Decimal)
Dim dv As New DataView(ds.Tables(0))
'dv.Sort = "date"
View 2 Replies
Aug 13, 2010
I'm trying to retrieve selected DataKeyValue and I'm getting this error.
[Code]....
View 2 Replies
Mar 8, 2010
I have a textbox that takes an integer value, and a submit button that when clicked passes the value to a detailsview to display the database record at that index.
What I'd like to do is, when the button is clicked, compare the number to the keys in the detailsview's datasource so that if the record ID doesn't exist, I can display a label telling the user that the ID# doesn't exist.
How would I go about doing this? Is there some sort of compare method for the datakeynames property?
View 6 Replies
Mar 11, 2011
How do display a list of data returned from the database like this.
[code]....
View 1 Replies
Aug 13, 2010
I have a gridview and would like to display one of 5 icons depending on the value returned from the database for that row (simply just A, B, C, D or E). Which event in my datagrid should I be looking at to check what value I'm getting? I presume once I can check a value I can simply set an image source using if statements?
View 4 Replies
Jul 22, 2010
Is it possible to bind data to specfic columns in Gridview?
I mean, if I send a query to my database and it returns 1 column, then bind that column to the first column in the gridview, then send another query and bind the resulting column from that query to the second column without erasing the data of the first column etc etc.
View 11 Replies
Dec 21, 2010
I have a listview control on the page.. when the page binds and the listview is presented, there should be only 6 records.. well those 6 are displayed corrected at the top, but then below that is the same 6 records.. and below that is the same 6 records.. this goes on 6 times for the page.
If only 1 record is returned by the query. the page lays out ok and functions as expected.. is there a configuration i need to make to the listview to prevent it from repeating itself the number of records it returns?
View 15 Replies
Jan 13, 2011
I am using a nested listview to display a seperate grid for each group of data returned from my db query. To get this working, I have adapted a piece of code to group the data prior to it being bound:
[Code]....
I am then using the following html markup:
[Code]....
[Code]....
This works as I want it to however some of the fields within the nested table need to be formatted as currency so I am trying to use Eval and {0:c} to do this however the moment I use Eval, the data items cannot be found
DataBinding: 'System.Data.DataRow' does not contain a property with the name '0'.
View 4 Replies
Jan 28, 2010
I have this specific task: I have a contacts table, and when users view a specific contact in details page I want to display a button in the page (doesn't matter anywhere, but inside the detailsview control next to the "edit" hyperlink is better), when it's clicked I want to grab all the info of this contact instance and write it to Response so user can save it through the save file dialog. So far I have two problems1. How do I access the contact? it's displaying on the page but when I tried detailsview.dataitem it returns null, e.result in the datasource selected event handler also returns null...2. I can get the button (outside the detailsview control) to trigger the file download dialog, but how do I achieve the same thing if the button is placed inside the details view which is in turn inside a updatepanel?
View 1 Replies
May 18, 2010
Currently I have
dlRSS.DataSource = GetRSSFeed("http://www.foodsafetynews.com/headlines.xml")
dlRSS.DataBind()
Function GetRSSFeed(ByVal strURL As String) As DataTable
'Get the XML data
Dim reader As XmlTextReader = New XmlTextReader(strURL)
'return a new DataSet
Dim ds As DataSet = New DataSet()
ds.ReadXml(reader)
Return ds.Tables(2)
End Function
<asp:DataList ID="dlRSS" runat="server" Width="100%" >
<ItemTemplate>
<strong><p><div><asp:HyperLink ID="TitleLink" runat="server" Text='<%# Eval("title") %>' Target="_blank" NavigateUrl='<%# Eval("link") %>'/></div></p></strong>
<strong><p> <div><asp:Label ID="SubtitleLabel" runat="server" Text='<%# Eval("description") %>' /></div></p></strong>
</ItemTemplate>
</asp:DataList>
But is returning all rows in RSS Feed I would only like top 5 or so
View 1 Replies
May 5, 2010
using asp.net/vb.net 2005
In the aspx page I have the EmptyDataText property set
[Code]....
However when no records are not returned I am not seeing the text "No Results Returned" I am populating the gridview using a SqlDataSource. I am not sure why this is happening but thinking about setting the value programmatically, does this make sense and if yes which gridview event should I do this? has anyone else experienced something like this before?
View 19 Replies
Sep 10, 2010
I am working on creating a stored procedure that will output a pivot table. In the pivot table will be either the string NULL or a number. How can I reformat this in ASP.NET so the NULL value becomes a blank cell in the gridview and the number (whatever it is) becomes an 'X' ?
View 3 Replies
May 20, 2010
I have a question involving the ItemDataBound EventI have a linkbutton, btnOverview, that is displayed in a DataList ItemTemplate.I would like to select 1 of 2 imageurls for this button based on the value of haseOverview which is a field returned by the SelectCommend of the sqlDataSourcefor the DataList. I am not sure of how to reference this field.I have highlighted what I think is he relevant code section below.
[Code]....
[Code]....
View 2 Replies
Jan 13, 2010
I need to format this date time into the format Day/Month/Year on the same template field.
I am avoiding doing this under SQL server because that will mean changing my data type in my dataset to string instead of data time which i do not want.
<asp:TemplateField HeaderText="Publish Date" SortExpression="PublishDate">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("PublishDate") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("PublishDate") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
View 4 Replies
Feb 6, 2010
Using C#, how can I check the total number of rows returned from a database when using a Repeater? The reason I need to check is I need to alter the presentation of the data when there is only 1 row returned.
View 9 Replies
May 7, 2015
I want to add items DropDownList Csharp using For next loop
int i;
for (i = 1; i <= 4; i = i +1) {
DropDownList1.Items.Add(i.ToString());
}
Code not working.
View 1 Replies
Jul 6, 2010
Just a bit of infor before we get to the code...
This is all in the Code Behind under the Page Load function.
Basically, I'm trying to convert an ASP page into ASP.NET. I've worked with ASP and PHP a lot more than I have with ASP.NET and I'm just having trouble with the syntax.
Here is the code:
[Code]....
View 3 Replies
Jan 1, 2011
I have int datatype declared in my store proc.
When I try to pass parameter from code behind in sqldatasource as :
SqlDataSource3.SelectParameters.Add(ContactNum",
System.TypeCode.Int32,
"1")
I get error "
Error converting data type nvarchar to int. "
View 3 Replies