.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

DataGridView object column 'data type' assignment

Posted By:      Posted Date: October 23, 2010    Points: 0   Category :.NET Framework
How do I assign a 'data type' to an 'unbounded' datagridview object

View Complete Post

More Related Resource Links

Calling a method with a class object as parameter data type.

   [WebMethod]    public string GetInfo(Customer inCust)    {        // Code in here    } I have a web service that resides on a remote server. I want to call a public method of theweb service named  "GetInfo". The method is shown above. The web service method expects a class object oftype "Customer". What I did to create a Customer object was to define in my asp.net project my own class named "Customer" which is exactlythe same as the class that belongs to the web service project on the remote server. I then created an instance of Customerand tried to call the web service passing in an object of type customer : my.Service ws = new my.Service(); // Get web service connectionCustomer aCustomer = new Customer();aCustomer.Initialize();ws.GetInfo(aCustomer) // call web service passing in a Customer object The problem is that the compiler gives me the following error: Value of type '_Default.Customer' cannot be converted to 'ws.Class1'. Here Default is refering to my Default.aspx.cs code. Why is this? Do I need to Cast my "aCustomer" class object to a type ofws.Customer ? How do I do that?

datagridview add data a column at a time

How do I add to a datagridview a column at a time? I see at http://msdn.microsoft.com/en-us/library/5s3ce6k8.aspx that it is possible to do it a row at a time. I was looking for something similar.      

Is there any way to populate an InfoPath form field with the data from the site content type column?


I have a Form library with a form template.

The templat has a field "Office name" which should not be a fixed list of values, but a dynamical list, feeded from a different type of form. I'm a novice with InfoPath - Sharepoint and I want to find out, how can I can give users a possibility to create and maintain a list of offices and also have this list as a selection list inside main library form - ALL inside one library, if possible.

I assumed that if I publish main form (Itinerary) as a library template form and lookup form (OfficeInfo) as a SiteContent, I should be able somehow to connect to siteContent column and it's information. But I cannot see how - Site Content Gallery is not appering as a Connection item.

Can I use SiteConenct for this purpose or there are other ways to create end-user lookup lists?

Thank you!


Multidimensional Arrays (or) ArrayLists and Object Data Type in SSIS

I want to create a multidimensional array dynamically in a Script Component and assign to a Object DataType and then use that variable in another Script Component, to retrieve the elements of the multidimensional array

Data retrive using xml type column



I am using following table to store user details.

CREATE TABLE [dbo].[TRN_User](
	[UserID] [bigint] IDENTITY(1,1) NOT NULL,
	[AccountNo] [int] NULL,
	[Title] [varchar](50) NULL,
	[FirstName] [varchar](100) NULL,
	[LastName] [varchar](100) NULL,
	[UserAttributes] [xml] NULL
	[UserID] ASC

UserAttributes is a xml type column and the data in that column is depend on the UserType. Following is a sample xml of a record.


Complex Matrix column data with different data type

I have a data like this

drop table #table
select 34 as A,17948 as B,0.19 as C,19 as D,16145 as E,'Jan' as Period into #table
Insert into #table
select 26 as A,14206 as B,0.18 as C,19 as D,13411 as E,'Feb' as Period
union all
select 38 as A,13037 as B,0.21 as C,18 as D,14974 as E,'Mar' as Period
select * from #table

From this #table i want the view as below format and is doable thru matrix report option in SSRS,but the problem i am running is that i cannot get in this type of data type format. If you look into it,i have column with header 'Jan' and it has data in different data type e.g money,number,percentage. I need to maintain this data type in order to do the calculation after it generates the report on excel spreadsheet. If i use the varchar for the column, it is not usable to me in the final report and i cannot do the calcualtion. Any workaround will be highly appreciated.

    Jan               Feb          Mar
A $34               $26          $26
B 17,

Unable to cast object of type 'System.Data.SqlClient.SqlCommand' to type 'System.IConvertible'.


















column - data type


Hi All,

My data is:

What data type should I use and how many posts should be?
This time use data type = numeric (18.4)
This is not good.
Do I need to be increased to (18.8)?

Please Help

Assigning External content type field column value using Client Object Model


I have a problem assinging External column value to ListItem object with client object model-based application I'm developing. To be precise, I am able to retrieve data related to external content type by reading external list created from this content type but I don't know how to properly use it to assign value to this field. By doing some research on my own I concluded that BDC ID column from external list is the way to go since it uniquely defines selected row from external list but that doesn't tell me much since I don't know what to do with it. Currently I ended up with partial solution - to assign plain string value of picker column but that makes this value visible only in "View Properties" option on Sharepoint and not in "Edit Properties" which pritty much makes sence since it isn't properly related to rest of the data in specific row. Does someone have a better solution for this?

Igor S.

Syntax error converting varchar value to a column od data type int


Hi everyone,

I'm having a problem where I've created a stored procedure with a dynamic ORDER BY clause and it's returning a syntax error:

Server: Msg 245, Level 16, State 1, Procedure usp_OrderBy, Line 4

Syntax error converting the varchar value 'Closed' to a column of data type int.

Here is the code that I'm trying to execute. It works fine if I take out the ID line:

CREATE PROCEDURE [Task_User].[usp_OrderBy]
  @orderBy varchar(100)
  SELECT ID, Status, PostedBy, Assigned, Subject
  FROM mainTable
    WHEN @orderBy = 'ID' THEN ID --When I take this out, it works
    WHEN @orderBy = 'Status' THEN Status
    WHEN @orderBy = 'PostedBy' THEN PostedBy
    WHEN @orderBy = 'Assigned' THEN Assigned
    WHEN @orderBy = 'Subject' THEN Subject
Any ideas as to what I can do to fix it?

Changing column Data Type when using merge replication: RFC on my SMO code.


I maintain an application for that uses SQL 2005 / 2008 for data persistence.
Some clients use Merge Replication (pull or push) to replicate data.

Some of the data the application stores should be "versioned". All versions of a row containing medical information should be stored, somewhere in a database. This means all updates and deletes to those rows should result in in 2 affected rows:

  • a copy of the row before the change
  • a row containing the change (or the deletion of the row in question)

I plan to achieve this using triggers on all the tables for wich "versioning" is required.
The old versions of a row may be stored in the same database, an other database (or a database on a linked server).

Unfortunalty, the AFTER UPDATE, DELETE triggers do not support TEXT, NTEXt an IMAGE data type columns.
Thus I am required to convert all text, ntext and image columns to their respective "new" data types, varchar(max), nvarchar(max) and varbinary(max).

This is not a big issue when the database is not published, but when it is... most articles (and posts) i've read suggest:

  1. Add a column of the target data type to the table, copy data from source column. rename columns and drop the source column.

  2. Create a temp table (with the s

Presenting Data with the DataGridView Control in .NET 2.0 > Defining Custom Column and Cell

in this link u can find the explanation about how to bind image column at run time.

Specifying the finder method for a business data connected list column's object picker.



I have a BDC xml file which specifies a finder and a specific finder method. These both work fine.

What I want to do is configure the application so that when connected to a list column the object picker uses my finder method rather than the specific finder method which it defaults to. Is this possible?

For further explination if you look at the following image http://i56.tinypic.com/2n22o3m.jpg

If I want to find the department using the objet picker I have to type the full identifier.

If I click the browse (address book icon) to popup the browse window I can then use my finder method. I want the initial object picker to use my find method and if there multiple matches be able to pick one using the popup you get when the message "No exact match was found." is displayed.

Hope this makes some sense!

Cheers Dave

Unable to cast object of type 'System.Data.DataSet' to type 'DataSet'.

Specifications : VS 2008 & SQL 2005 Express
Unable to cast object of type 'System.Data.DataSet' to type 'DataSet'.
I'm getting this error in cliend app, while passing values to the wcf service(iis),
WCF Sevice code
  public DataSet ListofAccounts(string custidno)
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConStrWestSideBank"].ConnectionString);
    SqlDataAdapter da = new SqlDataAdapter("select * from AccountDetails where vCustIdentityNo ='" + custidno + "'", con);
    DataSet ds = new DataSet();
    da.Fill(ds, "AccountDetails");
    return ds;
I'm unable to get this, i tried in many ways but no use, please help me. Follwing is the code,of button click event 
   ServiceReference1.ServiceClient svcobj = new

Bug: Does not change column type from nvarchar to ntext


Scenario: If you create a table with a column of type nvarchar, populate it with some content and try to modify it using the WebMatrix editor, from nvarchar to ntext, it does not display any error message or warning that this is not possible. It silently saves and reverts the change, back to nvarchar. Wasted some hours on this issue as I thought my column was ntext, but in fact was still nvarchar.

Expected behavior: It should change to ntext, or if SQL CE doesn't support that, it should notify the user that no change was applied.

Rendering data with HTML tags in the DD Gridview for a selected column


I am having trouble finding out where and how to HTML Encode a cell's data on the Dynamic Data (v4.0) gridview of List.aspx.  As a simple case, suppose I have formatted cell data that is A<br/>B in the DB.    Obviously, I want A stacked on B in the cell.

It seems gridView1.HtmlEncode = true has gone away.

So maybe I'll try to catch it on the RowDataBound event:

protected void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)

            if (e.Row.RowType == DataControlRowType.DataRow)
                // Html Encode the cells


but this event never fires?

Has anyone figured out how to properly render HTML tags data in the List.aspx's GridView1? 

If I figure this out, then I can add a MetaAttribute called something like [EncodeAsHtml(true)] and be on my way.  Thanks!

The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must



This is frustrating, and I don't know how to solve it.

I have a strange problem. I am adding a LinqDatasource object, and set the context:

        protected void LinqDataSource_ContextCreating(object sender, LinqDataSourceContextEventArgs e)
            e.ObjectInstance = new KaruselaDataContext(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

Then I get this error:
The type 'System.Data.Linq.DataContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.


On web.config I already have this:
<add assembly="System.Data.Linq, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

NOTE: The datacontext is in a different project (DLL proect) where I added a refernce to System.Data.Linq.

is there another way adding a refernce to a web project? or only though teh web.config?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend