DataBinding to a Web Service in ASP.NET 2.0
- Posted: Jun 05, 2006 at 5:21 AM
- 76,328 Views
- 15 Comments
Download
How do I download the videos?
- To download, right click the file type you would like and pick “Save target as…” or “Save link as…”
Why should I download videos from Channel9?
- It's an easy way to save the videos you like locally.
- You can save the videos in order to watch them offline.
- If all you want is to hear the audio, you can download the MP3!
Which version should I choose?
- If you want to view the video on your PC, Xbox or Media Center, download the High Quality WMV file (this is the highest quality version we have available).
- If you'd like a lower bitrate version, to reduce the download time or cost, then choose the Medium Quality WMV file.
- If you have a Zune, WP7, iPhone, iPad, or iPod device, choose the low or medium MP4 file.
- If you just want to hear the audio of the video, choose the MP3 file.
Right click “Save as…”
- High Quality WMV (PC, Xbox, MCE)
- MP3 (Audio only)
- Mid Quality WMV (Lo-band, Mobile)
- High Quality MP4 (iPad, PC)
- MP4 (iPod, Zune HD)
One of the cool new features of ASP.NET 2.0 is its rich declarative databinding. In addition to traditional techniques like databinding to a back-end SQL database, you can also databind to web services, using the ObjectDataSource.
In this DevNugget, Mid-Atlantic .net Developer Evangelist G. Andrew Duthie (aka .net DEvHammer) shows you how you can very quickly create a web service to return structured data using a .net 2.0 DataSet class, then how you can easily bind your web service to an ASP.NET 2.0 GridView control using the ObjectDataSource, including both displaying and updating data.
Comments Closed
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
Does DataGridView have an "Enable insert" option? I have not found such feature in DataGridView so far. Would you mind giving us directions to it?
Kindly regards,
Luciano Evaristo Guerche
Taboao da Serra, SP, Brazil
I'm not sure that there's a simple way to do that. Your best bet for inserts is to use something like the DetailsView control. You could add a DetailsView control to your page, along with an Add Row button or link, and only show the DetailsView when the Button/Link is displayed.
I'm sure that you could customize the behavior of the GridView to allow inserts directly from the control, I'm just not sure it'd be worth the effort, compared to using the built-in DetailsView control.
That said, a GridView doesn't provide an configurable means of inserting new data, i.e. there is no "enable insert" option. The GridView control does inherit the ability to support insert operations via an InsertCommand, much like a SelectCommand or DeleteCommand. You must write this manually, though. Furthermore, I found it necessary to create FooterTemplates to support this data entry and to create an EmptyDataTemplate to allow entry of initial items.
So, as mentioned: it can be done, but I think there are easier ways to do what you want.
Regards,
Jim Greer
I am self teaching and sometimes it is very hard to grasp basic concepts. This video is more advanced than me, please can anyone guide me with the basic concept of how I can create relationships between a database table and a web service datagrid.
Thanks
stampcoverman
Great information. I learned quite a bit. Even that this one will only run once. What am I to do with that <app settings for a dynamic port? Turn that feature off? Rebuild the web reference every time?
This one was fun to learn from. I downloaded the swf file and ran it in Irfanview. I must of got a glitch in the transfer though as Irfanview locked up just about at the end of building the service provider. Flash players are cool though. I wish more control was avalible like in most video players, you know the slider? It did run okay in IE and Firefox.
I saw the one on code snippets and started browsing the help files for more information on downloading them but it just gave me the run around. More on this would be cool because you use a screen cam not that I minded looking at Lisa. lol
VOE(Visual Objects Environment) de KB9AGT signing off.
P.S. I cannot run IIS on XP Home Edition.[C]
Finally, I have found what I needed. I have been searching all over the internet for binding a webservice to a datagrid.
I am new to web services. And, I have definitely been doing things the hard way. So, I need to have the web service create a method where it is using the table adapter? This way I can choose an Object as my data source and then have it point to my web service? Does it matter that I am referencing a WSDL instead of asmx file?
I have been choosing (none) as my data source and then binding the grid programmatically. I think the person who is providing me the WSDL is not sending me the correct web methods.
Thanks.
How i can changue the url of the webreference?
changue the url in code or in config
Thanks
This video seems to have problems. I have tried it on two computers and I get "Media Failure...". Has it been removed?
Not sure why the video is not displaying properly in the embedded version. You can still access the WMV directly by clicking the WMV icon next to "Formats" below the embedded video...that seems to work fine. Sorry for the difficulty, I'll see if I can figure out what's up.
Thanks to one of the kind folks on the Channel 9 team, we were able to isolate the issue and correct it. The video should work properly now.
Andrew
Hi!
First of all, great video,easy to follow, but something didn't work out for me: everything works fine until I get to the Edit part.
*Note: I'm adapting your version to a school project, so I'm translating everything to C# and replacing Author with Players (database,names, etc.)
*Note2: I'm pretty much a newbie
When I'm writing the PlayersTA.Update part, it expects 7 arguments (my Players table has 7 fields), but when I run the code, click Edit, change a value, then click update, I get this message:
"ObjectDataSource 'PlayersDataSource' could not find a non-generic method 'UpdatePlayers' that has parameters: FirstName, Number, Description, BirthDate, LastName, Picture, Original_ID, ID."
I'm not quite sure what the Original_ID field is, because the table doesn't contain it. If I try to write the Update code with 8 arguments, I can't even build it, because it says: No overload for method 'Update' takes '8' arguments.
I also noticed that you have two au_id arguments in your code, but don't explain it.
I guess that the solution is quite simple, and maybe I gave you too many details, but I wanted to make sure that everything is clear
.
Thanks in advance,
A
Remove this comment
Remove this thread
close