ASP.NET 3.5 ListView and Databinding a DropdownList inside InsertTemplate

What I was finding for binding a dropdown list in an insertemplate for a 3.5 Listview has been either erroneous or clunky. First the issue:

When triggering an Insert Template to appear, there is no event that occurs as the form is rendered, like the the Update form. So any dropdown list, pretty much needs to be filled before fact. Or not…..

I created a simple web control inherited from the dropdown, and have it load from a datasource on it’s load. With a couple of checks, it loads once, and doesn’t repeat the databind. While the code I  put here probably won’t work exactly as is outside of my app’s context (custom object collections are retrieved a bound) You’ll get the idea. Once you create the control, simply put it in the template. No additional work needed!


Imports System
Imports System.Collections.Generic
ImportsSystem.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
ImportsSystem.Web.UI.WebControls  <DefaultProperty("Text"), ToolboxData("<{0}:ServerControl1 runat=server></{0}:ServerControl1>")> _
Public ClassTypeDropDownList
InheritsDropDownList<Bindable(True), Category("Data"), DefaultValue(""), Localizable(True)> PropertyTypeName() As String
   Get
      Dim s As String = CStr(ViewState("TypeName"))
      If s Is Nothing Then
        Return "[" + Me.ID + "]"
      Else
        Return s
      End If
  End Get
  Set(ByVal Value As String)ViewState("TypeName") = Value
  End Set
End Property
<Bindable(True), Category("Data"), DefaultValue("False"), Localizable(True)> PropertyIsLoaded() As Boolean
Get
   IfViewState("IsLoaded") IsNot Nothing Then
     Return CBool(ViewState("IsLoaded"))
   Else
     Return False
   End If
End Get
Set(ByVal Value As Boolean)ViewState("IsLoaded") = Value
End Set
End Property

Private Sub ServerControl1_Load(ByVal sender As Object, ByVal e AsSystem.EventArgs) Handles Me.Load
	DimopRes AsdbhJRBusiness.OperationResult
	If Not Me.IsLoaded Then
		DimlItems As List(OfdbhJRBusiness.DataContracts.TypeContract)
		Dimotyp As NewdbhJRBusiness.Entities.TypeEntity(Me.TypeName) opRes = otyp.GetListItems
 		If opRes.Success = True ThenlItems =CType(opRes.data, List(OfdbhJRBusiness.DataContracts.TypeContract))
			Me.DataSource = lItems
			Me.DataBind()
			Me.IsLoaded = True

		End If
	otyp =Nothing


	End If
End Sub
End  Class
And here is what I've put in the aspx. Note the simple way to find to the value.  

 

<isd:TypeDropDownList runat="server" DataTextField="LongDesc"  

SelectedValue='<%# DataBinder.Eval(Container.DataItem, "AddressTypeGUID") %>' 

DataValueField="Id" ID="ddlAddresstype" TypeName="AddressType" /> 

 Hope this helps! I'll respond to any questions, but please be patient!

Android 1.5 is here!

So I see that Google has published the new OS. I’ve downloaded it, and plan to assess the new features and maybe how I can put a few apps out fast. TwitWit has graced me with the skillset needed to do some cool stuff.

Thanks for the responses

So sorry it’s been a while. Work has dealt me an overtime card that could last a couple of months, so I’ve been taking advantage of it. I think it’s a good thing, because it’s given me an opportunity to assess my goals with Android.  I’m a little discouraged by the (worthless) celebrity fanfare it’s received. It’s become…shallow. Mind you there are a few celebs out there who get it (BrentSpiner, donttrythis, PennGillette) but, the others have just ruined it for everyone else. I may continue efforts on TwitWit, for notoriety on the Twitter site, But plan to focus on areas that are scarce with development on the Android OS. Apparently, I’ve been secretive on my bio page. so I’ve updated it.

Uploading to TwitXR

Found these links helpful for creating an upload class capable of supporting TwitXR .
Upload multipart form using httpclient
Converting file to ByteArray

Decision on Pictures

I think I”ll go with TwitXR over TwitPic for their api. I’m no security expert, it seems to me that TwitXR api is more secure than others. TwitXR seems to at least cover themselves with some basic authentication, which I’m accustomed to. Also, I think this first version will not cache the images to the sd card. Maybe an option later.

Date formatting in Android for Twitter

This one kept me up at night. I thought I had the right format string, but my dates never worked write, though the strings were ok. Then I found this at http://svn.liferay.com/browse/plugins/trunk/portlets/twitter-portlet/docroot/WEB-INF/src/com/liferay/twitter/service/impl/FeedLocalServiceImpl.java?r=23183

 SimpleDateFormat sdf = new SimpleDateFormat( “EEE MMM d hh:mm:ss Z yyyy”);  �
Date createDate;
createDate = sdf.parse(<yourTwitterCreatedAtDateStringGoesHere>);

Ways to Implement an OnClick Listener in Android

I hate inline solutions, so I went in search of alternatives to the popular inline onclick listener.

I found the start of what I was looking for in this blog post

http://tseng-blog.nge-web.net/blog/2009/02/14/implementing-listeners-in-your-android-java-application/

I’m going to use a hybrid of inline. While I’ll create an online listener, they will always call a function outside the listener. This way, I ‘ve have the entire scope of the class available.

Developers for Wordpress?

It turns out that there doesn’t seem to be a lot of support from developers for Wordpress. I found an issue with some plug-ins that was occurring when under iis7, and using php. Apparently, a post tag wasn’t being passed in the variable. simply hard-coding it into the plug-in’s form action page fixed it nicely. Well, maybe I’ll need to make a bigger presence as well. And all I wanted to do is setup a blog!

Project TwitWit

My current project is one for the Android platform called TwitWit. It is a twitter client. Why another one of those you ask? Well, for the most part, it is a good pilot project to get accustomed the Android OS. Consider it a stepping stone for bigger and better. I’ll post screen shot soon. I’ll leave this post open for comments, so if anyone has a “gotta have” feature that no one else has, please post!

Welcome

Yes, this is my first endeavor at a blog. I’m not sure where it’s going, but it will definitely be oriented towards development.