4 Replies - 1601 Views - Last Post: 24 August 2011 - 01:44 AM Rate Topic: -----

#1 November-06  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 391
  • Joined: 04-January 11

Converting String to Gridview or other objects

Posted 24 August 2011 - 12:21 AM

Say, I want to convert a string to a Gridview.

So I tried this

Dim strGridView As String = params(1)
Dim gvw As GridView = DirectCast(strGridView, GridView)



But the strGridView had a blue underline that says string cannot be converted to GridView so I tried this

Dim strGridView As String = params(1)
Dim gvw As GridView = DirectCast(Me.Controls(strGridView), GridView)



But now it is giving the error gvwName cannot be converted to Integer.

Is it really being converted into an integer when I cast it like this?

How should I convert string into a gridview or another objects like checkbox?

Is This A Good Question/Topic? 0
  • +

Replies To: Converting String to Gridview or other objects

#2 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Converting String to Gridview or other objects

Posted 24 August 2011 - 12:39 AM

You mean a string to be a check box or a grid view? Duh! this is impossible it you cannt cast an egg to get a table......
May be you need to add that value to gridview?
Was This Post Helpful? 0
  • +
  • -

#3 November-06  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 391
  • Joined: 04-January 11

Re: Converting String to Gridview or other objects

Posted 24 August 2011 - 12:52 AM

Well, its possible since I just got a solution to my problem.

Just a little wind up from lots of thinking did the trick.
Was This Post Helpful? 0
  • +
  • -

#4 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Converting String to Gridview or other objects

Posted 24 August 2011 - 01:10 AM

This is surprising, can you share yor solution with the community please?
Was This Post Helpful? 0
  • +
  • -

#5 November-06  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 391
  • Joined: 04-January 11

Re: Converting String to Gridview or other objects

Posted 24 August 2011 - 01:44 AM

The string I am passing of course is an id or it would be impossible. Then I just used findcontrol. As easy as that.

But since I googled it before trying, I ended up using DirectCast because it is said in other forums that this should work and I overlooked the possibility of using findcontrol.

You see, I need to pass the objects' id in forcing postback then use its values again after postback. That's why I need to pass it as string then use it again as objects.

This post has been edited by November-06: 24 August 2011 - 01:52 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1