in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

This Blog

Syndication

News

Mar 17 2008   Commuting this AM I independently ran into 3 ex-colleagues from the same small firm. Now I know Perth isn't big, but that is just too weird & 'paranoidal'. So Chris, Dan and Sean - stop dabbling in Occult over IpEspFi V6 - it's freaking me out!

Feb 20 2008   Aussie day has been and gone and things have been hectic, but I'm now on a course with the irrepressible Clayton James - with many ideas to blog about!

Jan 21 2008   Back again, with the promised info on moving those web pages in code.

Jan 16 2008   I'm away for a few days for a Geraldton funeral (sniff), but back in Perth I'll have something to say about moving pages between webs...

Jan 14 2008   Happy New Year and a Happy New Blog to all - especially MOSS masters Mr P.CleverWorkarounds and Sezai "Yoda"!

Archives


G'Day MOSSuMS

 
View Mike Stringfellow's profile on LinkedIn  
 
 
Join me, Mike Stringfellow, in the upside down world of the baggy green MOSS. I hope you find my rantings useful, as I search out my own path through the challenges and opportunities that "the other MS" throws out.
 

Binding to lists in ye olde ascx user control


Welcome

This blog starts at the technical coal face, but I'm also going to let loose on:

  • .Net 
  • Build Events
  • Web Config Modifications
  • Features
  • Visual Studio
  • Workflow
  • and anything else I come across in fact!

So let's dive in with a nice quick and easy one.

When Two Worlds Collide 

I was integrating existing user controls into sharepoint, and wanted to replace xml data bindings with lists (but no other changes - I'm lazy like that).

But blow me if there wasn't much info beyond webparts and GUID references!

So this is the simplest solution I could come up with - no CAML or nesting yet, but I'll revisit that...

 <%@ Register Tagprefix="SPwebControls" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<asp:DropDownList ID="selCountry" runat="server" DataSourceID="dataSourceCountries" DataTextField="Title" DataValueField="CountryCode2Digit"></asp:DropDownList>
<SPwebControls:SPDataSource id="dataSourceCountries" runat="server" UseInternalName="True" DataSourceMode="List" SelectCommand="<View></View>" >
    <SelectParameters>
        <asp:Parameter Name="WebUrl" DefaultValue="{sitecollectionroot}"/>
        <asp:Parameter Name="ListName" DefaultValue="Countries"/>
       
<%-- <asp:Parameter Name="WebUrl" DefaultValue="someSubWeb"/> --%>
    </SelectParameters>
</SPwebControls:SPDataSource>

I hope this helps someone else - let me know if you improve this or test out dynamic filtering.

NB: For the non.netters, note that <%--  --%> can be used to prevent instantiation and rendering to the page.

Comments

 

Sezai Komur said:

Nice and simple, I like this design pattern which is used heavily in the out-of-the-box master pages and page layouts by Microsoft itself.

Two seperate controls, the SPDataSource provides data to the DropDownList to do the rendering, very nice.

January 14, 2008 5:43 PM
 

Links (1/15/2008) « Steve Pietrek’s SharePoint Stuff said:

Pingback from  Links (1/15/2008) &laquo; Steve Pietrek&#8217;s SharePoint Stuff

January 15, 2008 8:40 PM

Leave a Comment

(required )  
(optional )
(required )  
Add

About MikeS

I'm a freelance consultant with over 15 years in the IT industry, currently specialising in .net and MOSS projects in Perth, Western Australia.

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts