Monday, March 26, 2012

Pass value in "Inherits System.Web.UI.WebControls.DropDownList"?

I would like to pass a value in a class, that inherits 'DropDownList'. To pass this value, I tried to work with 'Sessions' and with 'Request.QueryString'. Unfortunately, both of them cannot be declared. How can I pass a value in this class after all?

This is the code I have at this moment:


Public Class ColoredDropDownList
Inherits System.Web.UI.WebControls.DropDownList

Protected Overrides Sub RenderContents(ByVal writer As System.Web.UI.HtmlTextWriter)

Dim ...etc..

MyConnection = New SqlConnection(connectionstring)
MyCommand = New SqlDataAdapter("SELECT bgcolor FROM buffer WHERE page='" + Session("fileName").ToString() + "'", MyConnection)

I hope someone can help me. Thanks!You can access them inside a control via Context property which returns reference to the current HttpContext. To access Request or Session that would be Context.Request or Context.Session and so on.

0 comments:

Post a Comment