Unable to cast object of type 'System.Data.DataView' to type 'System.Data.DataTable'.
what is my problem?
I'm working with GridView for sorting
The error message is that "Unable to cast object of type 'System.Data.DataView' to type 'System.Data.DataTable'"....
Dim m_DataTable As DataTable = GridView1.DataSource
How can I change the code above?
Well let's see, if your DataSource is a DataView, you can get its associated DataTable object using the .Table property:
Dim m_DataTable As DataTable = GridView1.DataSource.Table
or in a land of strict typing:
Dim m_DataTable As DataTable = CType(GridView1.DataSource, System.Data.DataView).Table
Hope tha...
Unable to cast object of type 'System.Data.DataView' to type 'System.Data.DataTable'.
When I click the sort hyperlink, I got this error mesg: Unable to cast object of type 'System.Data.DataView' to type 'System.Data.DataTable'. in line 5.How do I fix this? Thanks. 1 Protected Sub GVCRlisting_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles GVCRlisting.Sorting
2 GridViewSortExpression = e.SortExpression
3 Dim pageIndex As Integer = GVCRlisting.PageIndex
4
5 GVCRlisting.DataSource = SortDataTable(GVCRlisting.DataSource, False)
6 GVCRlisting....
SqlDataSource.Select Error: Unable to cast object of type 'System.Data.DataView' to type 'System.String'.
I am trying to use the select statement to put a field from my database using a SqlDataSource named 'FileBase.' I am using the following code: FileBase.SelectCommand = "SELECT Username FROM Files WHERE Filename = '" & myFileInfo.FullName & "'" myDataRow("Username") = CType(FileBase.Select(New DataSourceSelectArguments()), String)But when I run the code I get the following error:Server Error in '/YorZap' Application. Unable to cast object of type 'System.Data.DataView' to type 'System.String'. Description:...
SqlDataSource.Select Error: Unable to cast object of type 'System.Data.DataView' to type 'System.String'.
I am trying to put the data from a field in my database into a row in a table using the SQLDataSource.Select statement. I am using the following code: FileBase.SelectCommand = "SELECT Username FROM Files WHERE Filename = '" & myFileInfo.FullName & "'" myDataRow("Username") = CType(FileBase.Select(New DataSourceSelectArguments()), String)But when I run the code, I get the following error:Server Error in '/YorZap' Application. Unable to cast object of type 'System.Data.DataView' to type 'System.String'. Descri...
Unable to cast object of type 'System.Data.Common.DataRecordInternal' to type 'System.Data.DataRowView'.
Hi...
I have a ListView which is nested in the ItemTemplate of another ListView. If a "status" value in the inner ListView = 1, then I'd like to hide the "Add to cart" link. However, the inner ListView's ItemDataBound event results in the error: "Unable to cast object of type 'System.Data.Common.DataRecordInternal' to type 'System.Data.DataRowView'." I've thoroughly searched the forums, but have not found a solution to this seemingly straightforward problem. Here is the code; the error occurs at line 8. 1 protected void L...
Unable to cast object of type 'System.String' to type 'System.Data.DataRowView'
Hi, I am having this problem: Unable to cast object of type 'System.String' to type 'System.Data.DataRowView'I have two repeaters: One is for a list of terms and the other show the definition. What I am trying to do is, highlight the selected term.Here is the relevant code which has this error:private Color SetButtonBackColor(object dataItem){ Response.Write("<br />In SetButtonBackColor Function"); Response.Write("<br>dataItem in SetColor is: " +(string)((DataRowView)dataItem)["TermIndex"]); string _initial = (string) ((DataRowView)dataItem)["TermIndex"];
&n...
Unable to cast object of type 'System.Boolean' to type 'System.Data.SqlClient.SqlParameter'.
In my code this doesn't work:prms(0) = New SqlParameter("@QUERYTYPE", Data.SqlDbType.Int).value = 2I get the error:Unable to cast object of type 'System.Boolean' to type 'System.Data.SqlClient.SqlParameter'. But this does: prms(0) = New SqlParameter("@QUERYTYPE", Data.SqlDbType.Int)prms(0).Value = 2Any reason why?
You code
prms(0) = New SqlParameter("@QUERYTYPE", Data.SqlDbType.Int).value = 2
do evaluation:
1. if New SqlParameter("@QUERYTYPE", Data.SqlDbType.Int).value = 2, the result is Yes or No,
2. prms(0) =...
Unable to cast object of type 'System.IO.FileInfo' to type 'System.Data.DataRowView'.
This code below:
Dim DomainVariable As String
DomainVariable = Session("Domain")
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem ThenDim FileRow As DataRowView = e.Item.DataItem
Dim FileLink As HyperLink = e.Item.FindControl("FileHyperLink")Dim FileName As String = FileRow("Name")FileLink.NavigateUrl = String.Format("http://{0}/{1}", DomainVariable, FileName)
FileLink.Text = FileRow("Name")
End If
IS GENERATING THIS ERROR...............
Unable to cast object of type 'System.IO.Fil...
System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'
Hello , I am a data table with null able Columns.I am not able to catch the value for DBNull. I did set a value to be returned as empty in dataset. Here is the code where i am trying to catch.1 public List GetStores()
2 {
3 List tmpStore = new List();
4 StoresService.shopDBDataSet.StoresDataTable stores =
5 storesService.GetStores();
6 for (int i = 0; i < stores.Count ; i++)
7 {
8 Store store = new Store();
9 store.StoreID = stores[i].StoreID...
System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Byte[]'.
Hi All,
I am trying to retrieve a Picture from an SQL 2005 database. Here is my code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ListingID As String = (Request.QueryString("GUID"))
'Connect to the database and bring back the image contents & MIME type for the specified pictureUsing myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionStringListings").ConnectionString)
Const SQL As String = "SELECT [Pic1Ext], [Picture1] FROM [Listings] WHERE [ListingID] = @ListingID"C...
Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'.
Hi,
I have developed a custom server control for .NET Framework 2.0. The server control has a property named BinaryData of type byte[]. I marked this property to be data bindable. Now, I have varbinary(Max) type of field in my SQL Database and I have used SQLDataSource and bound this varbinary(Max) field with the property BinaryData (byte[]) of my control. It is working fine as long as the data value is not NULL. Now, In my control, I have handled the NULL value so that no Exception is thrown. Still, when I bind this property using the SQLDataSource, I get Error "Unable to cast object ...
Unable to cast object of type 'System.UInt32' to type 'System.String'?
Hi all,I'm trying to retrieve a column in my table (MySQL), this is the primary key of that table, and here is my code: public string GetAsocPKByUserName(string UserName)
{
MySqlConnection conn = new MySqlConnection();
MySqlCommand myCommand = new MySqlCommand();
string ASOC_PK = string.Empty;
try
{
conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
conn.Open();
myCommand = new MySqlCommand("SELECT Distinct ASOC_PK FROM asso...
Unable to cast object of type 'System.String[]' to type 'System.IConvertible'.
hi expert
i try get the string from request.querystring("CID")
from the error messege i know that is string[] (array)
how to convert it to int32 and request.querystring("CID") is int value
Line 19: protected void ObjectDataSourceCarPicture_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
Line 20: {
Line 21: e.InputParameters.Add("CID", Convert.ToInt32(Request.QueryString.GetValues("CID")) );
Line 22: // e.InputParameters.Add("CID", Convert.ToInt32( Convert.ToString( a Request.QueryString.GetValues("CID")))));
Line 23: ...
Unable to cast object of type 'System.Int64' to type 'System.String'
Hi friends I am getting the following error..."Unable to cast object of type 'System.Int64' to type 'System.String'." for the following line of code
if ((QSDealID) == (dr.GetString(1).ToString()))...............need ur help...Gurjeet,England
First of all, the ToString of the GetString method is not needed because the GetString will return a string. The prolem with your code is that QSDealID is of type System.Int64, right? So a Int64 can't be compared with a string. The DataReader have a method that can return a Int64, so instead of using GetString(1), ...