Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional display of controls....

Status
Not open for further replies.

wsmall73

Programmer
May 23, 2002
261
US
I am trying to allow certain users to view data that is 'standard' and edit it..... conditionally when it is non-standard I just want to show the data as table data within the table. I am trying to conditionally display either static text or a drop-down list box. I am not sure if this is heading in the right direction or whether I should be trying to do something in the itemcreated event... and where to go from here. Any help would be greatly appreciated....TIA

aspx.page

<td colspan=&quot;2&quot;>
<%# GetControl(DataBinder.Eval(Container.DataItem,&quot;base_task_stnd_ind&quot;))%>
</td>

codebehind...

public string GetControl(object stnd_ind)
{
if((bool)stnd_ind == true)
return &quot;<asp:DropDownList id='ddl_entity_type' runat='server' DataSource='<%# myDataSet %>' DataMember='EntityType' DataTextField='entity_type_desc' DataValueField='entity_type_no' Width='160px' />&quot;;
else
return &quot;<%#DataBinder.EvalContainer.DataItem,'entity_type_desc')%>&quot;;
}
 
You can't return a string which equates to a databound control like that... since you are already in the databinding event when this method is called.

Instead, return a control... already bound:

public Control GetControl(object stnd_ind){
Control output;
if((bool)stnd_ind){
//subtype to a dropdown list, bind it, return it
}
else{
//subtype to a label (or some other control),
// fill it's text property, and return it
}
return output;
}
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
thanks for the response...I am obviously a newbie...
will I have to create a new dataset within this function or can I somehow reference my original dataset (instantiated in the BindGrid() method)... then bind??? TIA
 
If you declare that dataset with class scope (ie not in the bindGrid() method), then yes, you should have no problem accessing it in any other class member.
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
I appreciate all the help link9...YR (you rock!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top