Link to home
Start Free TrialLog in
Avatar of codequest
codequest

asked on

Set Container.DataItem property programmatically

is it possible to set values like the one below for a label, programmatically?   If so, in what event would that take place, and what would the syntax look like?   Or, if there are reasons why this can only done on the page itself, that would be helpful to know.
=========================
dim label1 as new label
label.style.item...???  = ???
Font-Bold = '<%#CBool(GetFontBold(Container.DataItem("XZY")).tostring) %>'            <--- set this kind of value
                                                                                                                                           programmatically
(do something with label)
=========================

Thanks!


ASKER CERTIFIED SOLUTION
Avatar of samtran0331
samtran0331
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of codequest
codequest

ASKER

Thanks for the input.   I'd like to go in that direction and....

I need to make sure I can dynamically add controls to a panel in a gridview item template, the "how to" for which I'm having to find in the haystack,  

and

I'm going to be changing the visibility of labels, buttons and textboxes, and also their left position and width within the panel, based on Container.Item values and other conditions.

It seems like to do that I have to generate the css in advance, one for every possible case.  Which isn't impossible, because there are going to be a finite number of cases, but it makes the programming so difficult to control.   The key variables that I'm working with are spread out between the code behind and the style sheet, and there's the class id as an extra text name to remember.   If I want to make a change or adjustment relative to more than one control, you're having to keep a lot of stuff in my head at one time.  Since I have problems in that area, it seems more challenging.

I guess I don't understand what is fundamentally wrong with using the style variable.   I do know I've had much better luck controlling tables when I use styles, but that's not the case here.    Do you have any more behind the dislike of using styles.

Regardless, I'll give serious consideration to you input, because I've heard similar on several occasions.

Grazie!
Doing the research I recognize that the question was incoherent...if you're programmatically adding controls, then you set their values right then, or call the procedure directly,

Font-Bold = GetFontBold(somevariable)    

not through

Font-Bold = '<%#CBool(GetFontBold(Container.DataItem("XZY")).tostring) %>'    

.....pretty bizarre in retrospect!

Anyway, thanks for the prompting on this one.