Re: Programmatically changing CssStyle on Panels depending on DB values



Sorry that this is VB....

<mattsthompson@xxxxxxxxx> wrote in message
news:1119008553.651307.114810@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

> I am trying to change the look of a panel but only if that panel's ID
> is returned by a database lookup.
>
> I've tried using FindControl but this returns Controls and not
> WebControls and I'm having difficulty converting items.
>
> I'm coding in C#
>
> I was hoping to do something along the lines of:
>
> -- quote --
> Control hControl = Page.FindControl(dr.GetString(4));
>
> hControl.CssStyle = "MenuItemSelected";
> -- end quote --
>
> But the last line doesn't quite work ;o)
>

Sorry this is in VB

Call this on Fill() and/or whenever an event occurs, like a drop down is
selected or whatever....

.....snipit follows

Public Shared Sub SetupDynamicFields(ByVal formName As String, ByVal criteria As
String, ByVal page As Object)

Dim dr As SqlClient.SqlDataReader =
SqlHelper.ExecuteReader(Common.ConnectionString, "usp_GetControl_Info",
formName, criteria)

Do While dr.Read

'.... make vars, get & do stuff

Dim lbl As Label = page.FindControl(lblName)
Dim rfv As RequiredFieldValidator = page.FindControl(rfvName)
Dim tr As HtmlControls.HtmlTableRow = page.FindControl(trName)

If Not lbl Is Nothing Then
If dr.Item("Required") Then
lbl.CssClass = "StdFormLabelRequired"
Else
lbl.CssClass = "StdFormLabel"
End If
End If

'.... setup Required as Enabled to enable any on page validators, a form field
can be visible but not enabled, (read only) or a label.
'..... setup Visiblity
'.... setup entire tr visibility, easy way to dispay or hide form fields on
certain criteria, rather than having an empty tr or a hanging label.

.....snipit end

HTH

JeffP....


.



Relevant Pages

  • Re: Can continuous form be in a tabl control?
    ... setup as i described it. ... until the user sets criteria. ... criteria controls, and some code to set focus to the second tab page from ... Record Source: qrytblInvHist ...
    (microsoft.public.access.formscoding)
  • Re: DSUM non-contiguous criteria
    ... Thanks Lori for the clever setup. ... because the circular references couldn't seem to be cleared. ... table instead of the criteria table. ... My data is on one sheet and then on my separate query ...
    (microsoft.public.excel.worksheet.functions)
  • Re: DSUM non-contiguous criteria
    ... Thanks Lori for the clever setup. ... because the circular references couldn't seem to be cleared. ... table instead of the criteria table. ... My data is on one sheet and then on my separate query ...
    (microsoft.public.excel.worksheet.functions)
  • Re: criteria for date range
    ... I was using the same criteria as you suggested but I got it the wrong way ... Which makes me wonder if the "list by date" query I run is setup ... This will prompt the user for the two dates in the range. ...
    (microsoft.public.access.gettingstarted)