itemtemplate

ASP.NET GridView ItemTemplate

心不动则不痛 提交于 2019-12-11 01:18:44
问题 OK I have a GridView and there is a column that I want to be a link if a file exists, otherwise I just want it to be a label. Right now I am changing the controls on RowDataBound event handler using the Row passed in the args. I am not a big fan of this as I am hard coding the column ID, and if it ever changes I will need to remember to change this code. I was hoping I could do a conditional in the asp code to add a link if a property value is not null otherwise add a label. Is this possible?

VS 2010 SDK. Templates

*爱你&永不变心* 提交于 2019-12-10 20:27:37
问题 If you try and create an MVC3 project, you’ll see that you have an ability to add Controller or View with rc. And context menu you get on Controller folder with rc will magically suggest to add Controller while on the Views you’ll be suggested to add View. As I understand, to achieve this I need to bind somehow 4 things. Project template, Item template, T4 templates (used to generate Contoller class or View) and a wizard lieing between T4 and Intem template (within WizardExtension section in

Controls in ItemTemplate can't be called in Code Behind

懵懂的女人 提交于 2019-12-10 19:31:55
问题 I have server controls such as a popup with a gridview inside template fields in another gridview: <asp:TemplateField HeaderText="Actions"> <ItemTemplate> <asp:Button ID="viewHoursButton" runat="server" Text="View Hours" OnClick="viewHoursButton_OnClick" /> <ajaxToolkit:ModalPopupExtender ID="viewHoursPopup" runat="server" TargetControlID="viewHoursButton" PopupControlID="viewHoursPanel" CancelControlID="closeInfoPanelButton2" DropShadow="true"> </ajaxToolkit:ModalPopupExtender> <asp:Panel ID

How can I use a custom TabItem control when databinding a TabControl in WPF?

≡放荡痞女 提交于 2019-12-10 17:15:21
问题 I have a custom control that is derived from TabItem , and I want to databind that custom TabItem to a stock TabControl . I would rather avoid creating a new TabControl just for this rare case. This is what I have and I'm not having any luck getting the correct control to be loaded. In this case I want to use my ClosableTabItem control instead of the stock TabItem control. <TabControl x:Name="tabCases" IsSynchronizedWithCurrentItem="True" Controls:ClosableTabItem.TabClose="TabClosed" >

ComboBox with ItemTemplate that includes a button

那年仲夏 提交于 2019-12-10 10:19:48
问题 So, lets say I have a ComboBox with a custom data template. One of the items in the data template is a button: <ComboBox Width="150" ItemsSource="{Binding MyItems}"> <ComboBox.ItemTemplate> <DataTemplate> <Button Content="ClickMe" /> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> The problem with this is that the button eats the click, and the item does not get selected if the button is selected. This means that the pull-down does not go away, and no item is selected. I get WHY this is

WPF: ComboBox ItemTemplate doesn't get applied until I select the box

心不动则不痛 提交于 2019-12-08 09:45:22
问题 I have a ViewModel with a property that is a instance of a class. When I edit said ViewModel I have a ComboBox dynamically bound to a collection of the class. Problem is that if the Item has the instance before editing the ItemTemplate won't get applied until I select and expand the ComboBox. So when I pop up the Edit window the item appearing in the comboBox is myProject.myNameSpace.Type but as soon as I click the ComboBox it turns into NameOfType SomeInfo like it should be. XAML: <ComboBox

Databinding a List to a usercontrol in an Item Template in codebehind

霸气de小男生 提交于 2019-12-08 06:31:59
问题 I have a DataList like below: <asp:DataList runat="server" ID="myDataList"> <ItemTemplate> <uc:MyControl ID="id1" runat="server" PublicProperty='<%# Container.DataItem %>' /> </ItemTemplate> </asp:DataList> The Item Template is simply a registered usercontrol, MyControl. The DataSource for the DataList is a List<List<T>> and MyControl's PublicProperty is passed List<T> which it then peforms its own databinding on. This works fine, but I have a general aversion to databinding in the aspx/c

Add text from c# code to a gridview label

别来无恙 提交于 2019-12-08 06:07:22
问题 I need to add an specific text in an itemtemplate on a gridview... right now I have this in my gridview <asp:TemplateField HeaderText="Total" SortExpression="Total" ItemStyle-Width="100px"> <ItemTemplate> <asp:Label ID="lblTotal" runat="server" Text='<%#Math.Round(Convert.ToDouble(Eval("Total")), 2).ToString("C") + " M.N."%>'> </asp:Label> </ItemTemplate> </asp:TemplateField> in the part where it says <asp:Label ID="lblTotal" runat="server" Text='<%#Math.Round(Convert.ToDouble(Eval("Total")),

How to bind a Command to a ContextMenu from within an ItemTemplate?

淺唱寂寞╮ 提交于 2019-12-08 00:01:53
问题 I want to bind a certain command to a menuItem . The said menu item is part of a ContextMenu that is defined inside an ItemTemplate . Right now, what I have compiles and runs, but the command is never called. In the past, I had used a similar pattern to hook commands to buttons defined in an ItemTemplate with success. Anyone has any idea how I could accomplish this? XAML: <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006

Windows 8 XAML ListView with Header and Item Template columns should have same dynamic width

元气小坏坏 提交于 2019-12-07 05:13:29
问题 I am using a Listview with an Itemtemplate and a Headertemplate. Both templates contain 6 Columns. Everything is ok if i set a fixed column width for the templates - like in figure one. But i want to set the width to "Auto" for the items - but then i get figure 2... How to handle this? Is it possible to set the Header Column width with c#? - or any other solution? Figure 1: Figure 2: Code Listview: <ListView x:Name="DayanalyseListView" HorizontalAlignment="Center" VerticalAlignment="Top"