Search Results

Search found 654 results on 27 pages for 'itemtemplate'.

Page 14/27 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • MVVM Listbox DataTemplate SelectedItem

    - by StinkerPeter
    I am using a ListBox with a DataTemplate as shown below (xaml simplified and variable names changed). <ListBox ItemsSource="{Binding Path=ObservCollectionItems}" SelectedItem="{Binding Path=SelectedItemVar, Mode=TwoWay}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding SomeVar}" /> <Border> <StackPanel> <Button Content="String1" Command="{Binding DataContext.Command1} RelativeSource={RelativeSource FindAncestor, ListBox, 1}}" /> <Button Content="String2" Command="{Binding DataContext.Command2} RelativeSource={RelativeSource FindAncestor, ListBox, 1}}" /> </StackPanel> </Border> </StackPanel> </DataTemplate> <ListBox.ItemTemplate> </ListBox> I need the SelectedItemVar (dependency property) to update when I click on one of the buttons. SelectedItemVar is then used for the respective button's command. SelectedItemVar does update when I click on the TextBlock or the Border, but not when I click either button. I found a non-MVVM solution to this problem here. I do not want to add code in the file-behind to solve this, as they did in the link. Is there a clean solution that can be done in XAML. Beyond the non-MVVM solutions, I have not found anyone with this problem. I would have thought this was fairly common. Finally, I found this Command="{Binding DataContext.CommandName} RelativeSource={RelativeSource FindAncestor, ListBox, 1} for the Command binding. I do not fully understand what it is doing, but I do know that the command wasn't firing when I was binding directly to CommandName.

    Read the article

  • xml attribure in dataset

    - by raging_boner
    I want to bind Repeater control to Dataset which is filled with XML data, but i don't know how to show attributes inside repeater. Xml File: <root> <items> <item id="9" name="111111111111" description="111111245" views="1" galleryID="0" /> </items> </root> Repeater code: <asp:Repeater ID="rptrGalleries" runat="server"> <ItemTemplate> <a href='Page?id=<%#DataBinder.Eval(Container.DataItem, "id") %>'><%#DataBinder.Eval(Container.DataItem, "name") %></a> </ItemTemplate> </asp:Repeater> Codebehind: XDocument doc = XDocument.Load(Server.MapPath("~/xml/gallery.xml")); IEnumerable<XElement> items = from item in doc.Descendants("item") orderby Convert.ToDateTime(item.Attribute("lastChanges").Value) descending where int.Parse(item.Attribute("galleryID").Value) == 0 && bool.Parse(item.Attribute("visible").Value) != false select item; DataSet ds = new DataSet(); ds.ReadXml(new StringReader(doc.ToString())); rptrGalleries.DataSource = ds; rptrGalleries.DataBind(); When I compile site I receive this error: System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'id'.

    Read the article

  • Set Custom ASP.NET UserControl variables when its in a Repeater

    - by tnriverfish
    <%@ Register Src="~/Controls/PressFileDownload.ascx" TagName="pfd" TagPrefix="uc1" %> <asp:Repeater id="Repeater1" runat="Server" OnItemDataBound="RPTLayer_OnItemDataBound"> <ItemTemplate> <asp:Label ID="LBLHeader" Runat="server" Visible="false"></asp:Label> <asp:Image ID="IMGThumb" Runat="server" Visible="false"></asp:Image> <asp:Label ID="LBLBody" Runat="server" class="layerBody"></asp:Label> <uc1:pfd ID="pfd1" runat="server" ShowContainerName="false" ParentContentTypeId="55" /> <asp:Literal ID="litLayerLinks" runat="server"></asp:Literal> </ItemTemplate> </asp:Repeater> System.Web.UI.WebControls.Label lbl; System.Web.UI.WebControls.Literal lit; System.Web.UI.WebControls.Image img; System.Web.UI.WebControls.HyperLink hl; System.Web.UI.UserControl uc; I need to set the ParentItemID variable for the uc1:pdf listed inside the repeater. I thought I should be able to find uc by looking in the e.Item and then setting it somehow. I think this is the part where I'm missing something. uc = (UserControl)e.Item.FindControl("pfd1"); if (uc != null) { uc.Attributes["ParentItemID"] = i.ItemID.ToString(); } Any thoughts would be appreciated. Also tried this with similar results... when I debug inside my usercontrol (pfd1) the parameters I am trying to set have not been set. uc = (UserControl)e.Item.FindControl("pfd1"); if (uc != null) { uc.Attributes.Add("ContainerID", _cid.ToString()); uc.Attributes.Add("ParentItemId", i.ItemID.ToString()); }

    Read the article

  • how to find a control inside ItemsPanelTemplate in wpf?

    - by kakopappa
    I am trying to access a Grid inside the DataTemplate while the ItemsControl is binded by ItemsSource. this is the full XMAL code, How do i find a certain element from outside? for (int i = 0; i < allViewControl.Items.Count; i++) { var container = allViewControl.ItemContainerGenerator.ContainerFromItem(allViewControl.Items[i]) as FrameworkElement; var grid = allViewControl.ItemTemplate.FindName("grid", container) as DataGrid; } i found this always returning null ? <ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"> <ItemsControl x:Name="allViewControl" Focusable="False" HorizontalContentAlignment="Center" Grid.IsSharedSizeScope="true" ItemsSource="{Binding AllClassCharacters}" ItemTemplate="{StaticResource CharacterViewModelTemplate}" > <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Extensions:AnimatedWrapPanel IsItemsHost="true" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </ScrollViewer> <DataTemplate x:Key="CharacterViewModelTemplate" DataType="{x:Type ViewModel:CharacterViewModel}"> <Grid x:Name="grid" Width="200" Height="Auto" MinHeight="115" Margin="1" MinWidth="130" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Background="#66000000" > <Grid.RowDefinitions> <RowDefinition Height="70"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <ProgressBar x:Name="playerProgressBar" VerticalAlignment="Top" Background="Transparent" Height="5" Width="Auto" Value="0" Visibility="Collapsed" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan ="2" Grid.RowSpan="2" Foreground="White" BorderThickness="0" Style="{DynamicResource ProgressBarStyle1}" /> </Grid>

    Read the article

  • Regular input in ASP.NET

    - by coffeeaddict
    Here's an example of a regular standard HTML input for my radiobuttonlist: <label><input type="radio" name="rbRSelectionGroup" checked value="0" />None</label> <asp:Repeater ID="rptRsOptions" runat="server"> <ItemTemplate> <div> <label><input type="radio" name="rbRSelectionGroup" value='<%# ((RItem)Container.DataItem).Id %>' /><%# ((RItem)Container.DataItem).Name %></label> </div> </ItemTemplate> </asp:Repeater> I removed some stuff for this thread, one being I put an r for some name that I do not want to expose here so just an fyi. Now, I would assume that this would or should happen: Page loads the first time, the None radio button is checked / defaulted I go and select a different radiobutton in this radiobutton list I do an F5 refresh in my browser The None radio button is pre-selected again after it has come back from the refresh but #4 is not happening. It's retaining the radiobutton that I selected in #2 and I don't know why. I mean in regular HTML it's stateless. So what could be holding this value? I want this to act like a normal input button. I know the question of "why not use an ASP.NET control" will come up. Well there are 2 reasons: The stupid radiobuttonlist bug that everyone knows about I just want to brush up more on standard input tags We are not moving to MVC so this is as close as I'll get and it's ok, because the rest of the team is on par with having mixed ASP.NET controls with standard HTML controls in our pages Anyway my main question here is I'm surprised that it's retaining the change in selection after postback.

    Read the article

  • Pass Parameter to Subroutine in Codebehind

    - by Sanjubaba
    I'm trying to pass an ID of an activity (RefNum) to a Sub in my codebehind. I know I'm supposed to use parentheses when passing parameters to subroutines and methods, and I've tried a number of ways and keep receiving the following error: BC30203: Identifier expected. I'm hard-coding it on the front-end just to try to get it to pass [ OnDataBound="FillSectorCBList("""WK.002""")" ], but it's obviously wrong. :( Front-end: <asp:DetailsView ID="dvEditActivity" AutoGenerateRows="False" DataKeyNames="RefNum" OnDataBound="dvSectorID_DataBound" OnItemUpdated="dvEditActivity_ItemUpdated" DataSourceID="dsEditActivity" > <Fields> <asp:TemplateField> <ItemTemplate> <br /><span style="color:#0e85c1;font-weight:bold">Sector</span><br /><br /> <asp:CheckBoxList ID="cblistSector" runat="server" DataSourceID="dsGetSectorNames" DataTextField="SectorName" DataValueField="SectorID" OnDataBound="FillSectorCBList("""WK.002""")" ></asp:CheckBoxList> <%-- Datasource to populate cblistSector --%> <asp:SqlDataSource ID="dsGetSectorNames" runat="server" ConnectionString="<%$ ConnectionStrings:dbConn %>" ProviderName="<%$ ConnectionStrings:dbConn.ProviderName %>" SelectCommand="SELECT SectorID, SectorName from Sector ORDER BY SectorID"></asp:SqlDataSource> </ItemTemplate> </asp:TemplateField> </Fields> </asp:DetailsView> Code-behind: Sub FillSectorCBList(ByVal RefNum As String, ByVal sender As Object, ByVal e As System.EventArgs) Dim SectorIDs As New ListItem Dim myConnection As String = ConfigurationManager.ConnectionStrings("dbConn").ConnectionString() Dim objConn As New SqlConnection(myConnection) Dim strSQL As String = "SELECT DISTINCT A.RefNum, AS1.SectorID, S.SectorName FROM Activity A LEFT OUTER JOIN Activity_Sector AS1 ON AS1.RefNum = A.RefNum LEFT OUTER JOIN Sector S ON AS1.SectorID = S.SectorID WHERE A.RefNum = @RefNum ORDER BY A.RefNum" Dim objCommand As New SqlCommand(strSQL, objConn) objCommand.Parameters.AddWithValue("RefNum", RefNum) Dim ad As New SqlDataAdapter(objCommand) Try [Code] Finally [Code] End Try objCommand.Connection.Close() objCommand.Dispose() objConn.Close() End Sub Any advice would be great. I'm not sure if I even have the right approach. Thank you!

    Read the article

  • How to write a file that called from a database on a page?

    - by Mehmet Kaleli
    Hi. I have a "news" page that belongs to a company. All news have a header, detail and html page and they come from database. So i have to print those html pages in a repeater on my "news.aspx". But i couldnt write dynamically. How can i do it or is there anyway else? <asp:Repeater ID="news" runat="server" OnItemDataBound="news_OnItemDataBound"> <ItemTemplate> <asp:HiddenField ID="newsid" runat="server" Value='<%#DataBinder.Eval(Container.DataItem,"newsid") %>' /> <tr> <td class="haberler-sayfasi-habermetni" style="width:580px;padding-bottom:30px;"> <h1 class="haberler-sayfasi-haberbasligi" style="background-image:url(images/haber-ikon.jpg); background-repeat:no-repeat;padding-left:25px;"> <%#DataBinder.Eval(Container.DataItem,"newsheader") %>/h1> <br /> <%#DataBinder.Eval(Container.DataItem,"newsspot") %> <br /><br /> <% **Response.WriteFile('dynamical filename with path');** %> </td> </tr> </ItemTemplate> </asp:Repeater>

    Read the article

  • ASP.NET ListView, custom DataSources, and editing items

    - by Andrew Shepherd
    The MSDN walkthroughs provide a number of examples where you can drag a DataSource from the toolbox, run through some simple configuration steps, then drag a ListView onto the screen, point it at the DataSource, and hey - you've got full table editing. Now I'm trying to write my own DataSource class (a class that implements System.Web.UI.IDataSource) and my own DataSourceView class. I now assign an instance of this custom DataSource class to the ListView.DataSource propery. The display of all the items is working well. However, updating, inserting and deleting just is not working. I'm overriding every function I can in my DataSourceView class, and they just aren't being called. This is such a huge topic, I'll focus this question on one simple example: When you press the "Edit" button (the button inside the ItemTemplate with a CommandName of "Edit", you expect the ItemTemplate to be replaced by an EditItemTemplate. This did not happen. The only way I could get it to happen was to handle the onitemediting event. protected void _listViewPublicHolidays_ItemEditing(object sender, ListViewEditEventArgs e) { _listViewPublicHolidays.EditIndex = e.NewEditIndex; _listViewPublicHolidays.DataBind(); } This is hardly a problem, but how come I had to do it at all? In the MSDN walkthroughs where I attach a ListView to a LinqDataSource, this code doesn't have to be written. Can someone who's been here before hazard a guess as to what would be different or missing in my custom datasource?

    Read the article

  • How to display rich text in tooltip ASP.Net ?

    - by mokokamello
    Experts ! i use the following code to display a tooltip <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="AccessDataSource1"> <Columns> <asp:CommandField ShowEditButton="True" /> <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" /> <asp:BoundField DataField="datefu" HeaderText="date" SortExpression="datefu" /> <asp:TemplateField HeaderText="title" SortExpression="titlefu"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("titlefu") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <a href="#" title="<asp:Literal ID="Label1" runat="server" Text='<%# Eval("fu") %>'/>"/> <asp:Label ID="NamePatientLabel" runat="server" Text='<%# Eval("titlefu") %>' /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> display the following result however when i edit the text as follows (making it bold and red in another gridview containing rich text editor) i get the following (as a formatting result in the second grid view) however when i view in the first gridview to display the tooltip i get the following reult i really need your help to display the tooltip as rich text

    Read the article

  • binding a command inside a listbox item to a property on the viewmodel parent

    - by giddy
    I've been working on this for about an hour and looked at all related SO questions. My problem is very simple: I have HomePageVieModel: HomePageVieModel +IList<NewsItem> AllNewsItems +ICommand OpenNewsItem My markup: <Window DataContext="{Binding HomePageViewModel../> <ListBox ItemsSource="{Binding Path=AllNewsItems}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock> <Hyperlink Command="{Binding Path=OpenNews}"> <TextBlock Text="{Binding Path=NewsContent}" /> </Hyperlink> </TextBlock> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> The list shows fine with all the items, but for the life of me whatever I try for the Command won't work: <Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel, AncestorLevel=1}}"> <Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel,**Mode=FindAncestor}**}"> <Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel,**Mode=TemplatedParent}**}"> I just always get : System.Windows.Data Error: 4 : Cannot find source for binding with reference .....

    Read the article

  • WPF Empty Row in ItemsControl Binding with ObservableCollection

    - by YoMo
    I have ItemsControl Binding with ObservableCollection, every think is oky excipt when ObservableCollection was empty the ItemsControl showing one empty row !! <ItemsControl Visibility="Visible" ItemsSource="{Binding ocItemsinInvoice,Mode=TwoWay}" x:Name="test" Margin="10,-32,0,207" Width="412" HorizontalAlignment="Left"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <UniformGrid Columns="1" VerticalAlignment="Top" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <Button x:Name="btnOpenInvoice" Style="{StaticResource OpenInvoicesButton}" FontSize="12" Width="300" Height="60" Foreground="#ff252526"> <StackPanel Orientation="Vertical"> <TextBlock Text="{Binding Item.ItemName}" HorizontalAlignment="Center" VerticalAlignment="Center" /> </StackPanel> </Button> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> How can I remove it?

    Read the article

  • gridview image column problem

    - by jame
    Work on vs05 C# asp.net .My SQL Syntax is :**** if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Images]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[Images] GO CREATE TABLE [dbo].[Images] ( [ID] [numeric](18, 0) IDENTITY (1, 1) NOT NULL , [ImageName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [Image] [image] NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO I want to show this Images table values in a grid view.....I do it ...but the image value can not show ....asp.net syntax for gridview is <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"> <Columns> <asp:BoundField DataField="ImageName" HeaderText="ImageName" /> <asp:TemplateField HeaderText="Image"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("Image") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Image") %>' /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> i write the below code on pageload event. i want images table values must shown when the page is load... string strSQL = "Select * From Images"; DataTable dt = clsDB.getDataTable(strSQL); this.GridView2.DataSource = dt; this.GridView2.DataBind(); Why not i get the image on my image column of the gridview.....what's the problem is how to solve?

    Read the article

  • How to access the value of the Label present inside Datagrid asp.net using jquery?

    - by vini
    <asp:DataGrid ID="datagrid1" runat="server" AutoGenerateColumns="False" Width="100%" DataKeyField="Expr1" OnItemCommand="datagrid1_ItemCommand" EmptyDataText="No Records Found" > <HeaderStyle BackColor="#2E882E" Font-Bold="True" ForeColor="#FFFFCC" HorizontalAlign="Left" /> <Columns> <asp:TemplateColumn HeaderText=""> <ItemTemplate> <table> <tr> <td class="style1"> <asp:Label ID="lblStatus" runat="server" Text='<%# Eval("Status") %>'></asp:Label> </td> </tr> </table> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> How can i access this Status Label value using jquery Please help var DataGrid1 = $("<%=datagrid1.ClientID %>"); var status = $(DataGrid1).children("lblStatus").get(0).innerHTML; Will the above code work?

    Read the article

  • Change the source of an image by clicking a thumbnail (without jQuery preferably using UpdatePanel)

    - by Batu
    For example, i have this ImageViewer.ascx UserControl: <div class="ImageTumbnails"> <asp:ListView ID="ImageList" runat="server" ItemPlaceholderID="ItemContainer"> <LayoutTemplate> <asp:PlaceHolder ID="ItemContainer" runat="server" /> </LayoutTemplate> <ItemTemplate> <asp:HyperLink runat="server" NavigateUrl='<%# Link.ToProductImage(Eval("ImageFile").ToString())%>'> <asp:Image runat="server" ImageUrl='<%# Link.ToThumbnail(Eval("ImageFile").ToString()) %>' /> </asp:HyperLink> </ItemTemplate> </asp:ListView> </div> <div class="ImageBig"> <asp:Image ID="ProductImageBig" runat="server" ImageUrl="" /> </div> When the thumbnail is clicked it will change the source of ProductImageBig with its hyperlink target. How can i achieve this using UpdatePanel ? ( Or will i be able to )

    Read the article

  • CSS call from code behind not working

    - by SmartestVEGA
    I have the following entries in the css file. a.intervalLinks { font-size:11px; font-weight:normal; color:#003399; text-decoration:underline; margin:0px 16px 0px 0px; } a.intervalLinks:link { text-decoration:underline; } a.intervalLinks:hover { text-decoration:none; } a.intervalLinks:visited { text-decoration:underline; } a.selectedIntervalLink { font-size:12px; font-weight:bold; color:#003399; text-decoration:none; margin:0px 16px 0px 0px; } a.intervalLinks:active { text-decoration:underline; font-size:large ; } Whenever i take the click on some links (not shown) which is embedded in the webpage ..i can see the change in the link a.intervalLinks:active { text-decoration:underline; font-size:large ; (the font of the link will become large) but after clicking the page refreshes ..the changes will go away i want to keep the change for ever in that link ...even there is a page refresh i understood that ..this can achieved only throughg the code behind of asp.net Following code should work:but unfortunately its not ..could anyone help? protected override void OnInit(EventArgs e) { rptDeptList.ItemDataBound += new RepeaterItemEventHandler(rptDeptList_ItemDataBound); } void rptDeptList_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.DataItem == null) return; LinkButton btn = (LinkButton)e.Item.FindControl("LinkButton1"); btn.Attributes.Add("class", "intervalLinks"); } Current html code for links has been shown below : <ItemTemplate> <div class='dtilsDropListTxt'><div class='rightArrow' ></div> <asp:LinkButton ID="LinkButton1" runat="server" Text=<%#DataBinder.Eval(Container.DataItem, "WORK_AREA")%> CssClass="intervalLinks" OnClick="LinkButton1_Click" ></asp:LinkButton> </div> </ItemTemplate> Could anyone help?

    Read the article

  • Set focus to a button in a new TabItem

    - by Jan
    I use a TabControl to display a list of items. The ItemView is a separate control I wrote. <TabControl SelectedItem="{Binding CurrentItem}" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding ItemList}"> <TabControl.ContentTemplate> <DataTemplate> <ctrls:ItemView/> </DataTemplate> </TabControl.ContentTemplate> <TabControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding ShortItemDescription}"/> </DataTemplate> </TabControl.ItemTemplate> </TabControl> If the user presses a Button a new ViewModel is added to the list of ViewModels and the TabControl displays it as a new tab. After adding the new tab is selected. <Button Command="{Binding AddItemCommand}" Content="Add item"/> Inside of the new ViewModel is a button that needs to be focused each time a new tab is added. I have tried to use the FocusManager and the Initialized event in the ItemView but these are only called for the first time I add a new tab. <UserControl x:Class="ItemView" ... Initialized="ViewInitialized"> <Grid> ... <!-- Set focus to this button --> <Button Content="Search" Command="{Binding SearchCommand}" Name="SearchButton" Grid.Column="0" Grid.Row="0"/> </Grid> </UserControl> Any ideas?

    Read the article

  • ASP.NET: "Object Required" when repeating LinkButtons in an UpdatePanel

    - by MStodd
    I have an UpdatePanel which has a Repeater repeating LinkButtons. When I click a LinkButton, the page does a partial postback, then I get a javascript error: "Object required". I tried debugging the javascript, but couldn't get a call stack. If I remove the UpdatePanel, the LinkButtons do a full postback, and they disappear from the page. How can I get this UpdatePanel to work? <ajax:UpdatePanel ID="wrapperUpdatePanel" runat="server" UpdateMode="Always"> <ContentTemplate> <asp:Repeater ID="endpointRepeater" runat="server" OnItemDataBound="EndpointDataBound"> <HeaderTemplate> <div class="sideTabs"> <ul> </HeaderTemplate> <ItemTemplate> <li> <asp:LinkButton ID="endpointLink" runat="server" OnClick="EndpointSelected" /> </li> </ItemTemplate> <FooterTemplate> </ul> </div> </FooterTemplate> </asp:Repeater> </ContentTemplate> </ajax:UpdatePanel> binding code: protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { this.SelectedEndpoint = Factory.Get<IEndpoint>(Enums.EndPoints.Marketing); } IEndpointCollection col = EndpointCollection.GetActivelySubscribingEndpointsForPart(this.Item); if (this.Item.IsGdsnItem) col.Add(Factory.Get<IEndpoint>(Enums.EndPoints.Gdsn)); if (col.Count > 0) col.Insert(0, Factory.Get<IEndpoint>(Enums.EndPoints.Marketing)); this.endpointRepeater.DataSource = col; this.endpointRepeater.DataBind(); if (this.endpointRepeater.Items.Count > 0) { LinkButton lb = this.endpointRepeater.Items[0].FindControl("endpointLink") as LinkButton; this.EndpointSelected(lb, new EventArgs()); } } thanks, mark

    Read the article

  • binding a command inside a listbox item to a property on the viewmodel parent

    - by gideon
    I've been working on this for about an hour and looked at all related SO questions. My problem is very simple: I have HomePageVieModel: HomePageVieModel +IList<NewsItem> AllNewsItems +ICommand OpenNews My markup: <Window DataContext="{Binding HomePageViewModel../> <ListBox ItemsSource="{Binding Path=AllNewsItems}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock> <Hyperlink Command="{Binding Path=OpenNews}"> <TextBlock Text="{Binding Path=NewsContent}" /> </Hyperlink> </TextBlock> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> The list shows fine with all the items, but for the life of me whatever I try for the Command won't work: <Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel, AncestorLevel=1}}"> <Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel,**Mode=FindAncestor}**}"> <Hyperlink Command="{Binding Path=OpenNewsItem, RelativeSource={RelativeSource AncestorType=vm:HomePageViewModel,**Mode=TemplatedParent}**}"> I just always get : System.Windows.Data Error: 4 : Cannot find source for binding with reference ..... Update I am setting my ViewModel like this? Didn't think this would matter: <Window.DataContext> <Binding Path="HomePage" Source="{StaticResource Locator}"/> </Window.DataContext> I use the ViewModelLocator class from the MVVMLight toolkit which does the magic.

    Read the article

  • Master Detail same View binding controls

    - by pipelinecache
    Hi everyone, say I have a List View with ItemControls. And a Details part that shows the selected Item from List View. Both are in the same xaml page. I tried everything to accomplish it, but what do I miss? <!-- // List --> <ItemsControl ItemsSource="{Binding Path=Model, ElementName=SomeListViewControl, Mode=Default}" SnapsToDevicePixels="True" Focusable="False" IsTabStop="False"> <ItemsControl.ItemTemplate> <DataTemplate> <SomeListView:SomeListItemControl x:Name=listItem/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> <!-- // Details --> <Label Content="Begindatum" FontSize="16" VerticalAlignment="Center" Grid.Row="1" Margin="2,0,0,0"/> <TextBox x:Name="Begindatum" Grid.Column="1" Grid.Row="1" Text="{Binding Path=BeginDate, ElementName=listItem,Converter={StaticResource DateTimeConverter}, ConverterParameter=dd-MM-yyyy}" IsEnabled="False" Style="{DynamicResource TextBoxStyle}" MaxLength="30"/> public event EventHandler<DataEventArgs<SomeEntity>> OnOpenSomething; public ObservableCollection<SomeEntity> Model { get { return (ObservableCollection<SomeEntity>)GetValue(ModelProperty); } set { Model.CollectionChanged -= new NotifyCollectionChangedEventHandler(Model_CollectionChanged); SetValue(ModelProperty, value); Model.CollectionChanged += new NotifyCollectionChangedEventHandler(Model_CollectionChanged); UpdateVisualState(); } } public static readonly DependencyProperty ModelProperty = DependencyProperty.Register("Model", typeof(ObservableCollection<SomeEntity>), typeof(SomeListView), new UIPropertyMetadata(new ObservableCollection<SomeEntity>(), new PropertyChangedCallback(ChangedModel))); private static void ChangedModel(DependencyObject source, DependencyPropertyChangedEventArgs e) { SomeListView someListView = source as SomeListView; if (someListView.Model == null) { return; } CollectionView cv = (CollectionView)CollectionViewSource.GetDefaultView(someListView.Model); } private void Model_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (Model == null) { return; } }

    Read the article

  • Can't set Visible attribute in ASP.NET Panels

    - by RichW
    I am having trouble with visible attribute of an ASP.NET Panel control. I have a page that calls a database table and returns the results in a datagrid. Requirements If some of the returned values are null I need to hide the image that's next to it. I am using a Panel to determine whether to hide or show the image but am having trouble with the statement: visible='<%# Eval("addr1") <> DBNull.Value %>' I have tried these as well: visible='<%# Eval("addr1") <> DBNull.Value %>' visible='<%# IIf(Eval("addr1") Is DbNull.Value, "False","True") %>' Code is below: <asp:TemplateField > <ItemTemplate> <%# Eval("Name")%> <p> <asp:Panel runat="server" ID="Panel1" visible='<%# Eval("addr1") <> DBNull.Value %>'> <asp:Image Id="imgHouse" runat="server" AlternateText="Address" SkinId="imgHouse"/> </asp:Panel> <%# Eval("addr1") %><p> </ItemTemplate> </asp:TemplateField> What am I doing wrong? Edit If I use visible='<%# IIf(Eval("addr1") Is DbNull.Value, "False","True") %>' I get the following error: Compiler Error Message: CS1026: ) expected

    Read the article

  • Row Prefix - ItemsControl with UniformGrid

    - by tenfour
    I am using an ItemsControl to display a List<byte> in hex. The ItemsPanelTemplate is a UniformGrid with a fixed number of columns: <ItemsControl HorizontalAlignment="Left" VerticalAlignment="Top" ItemsSource="{Binding}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <UniformGrid Columns="16"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding StringFormat='\{0:X2\}'}" Margin="5,5,5,0"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> I'd like to prefix each row with an 'Address' column, just like you'd see with the Notepad++ 'HEX-Editor' plugin. That is, since I have 16 columns, each row should be prefixed something like this: 0000 [00 01 02 .... 0F] 0010 [10 11 12 .... 1F] 0020 [20 21 22 .... 2F] ... Any suggestions?

    Read the article

  • Why might a silverlight ListBox on Windows Phone not allow me scroll all the way down to the bottom?

    - by Byron Sommardahl
    I have a ListBox in a grid that gets databound when the page loads... pretty straightforward. The problem I'm having is that, after the box is databound, I can scroll... but not all the way to the bottom of the list. It stops an item or two short and won't let me scroll anymore. Here's the listbox XAML: <Grid x:Name="ContentGrid" Grid.Row="2"> <ListBox x:Name="lbFeed" ItemsSource="{Binding Items}" SelectionChanged="lbFeed_SelectionChanged" VerticalAlignment="Top" Width="480"> <ListBox.ItemTemplate> <DataTemplate x:Key="MyDataTemplate"> <StackPanel Orientation="Vertical" Width="430"> <TextBlock Text="Some text" TextAlignment="Center" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Grid> I can post more code, but I'm still getting my feet wet in XAML and I'm not sure what might be causing this. If you need more context, let me know and I'll add it here.

    Read the article

  • Why is my Repeater null in code behind?

    - by Rob Stevenson-Leggett
    I'm just starting a new project and I am getting some really weird stuff happening. ASP.NET 3.5, VS2008. I've tried rebuild, close VS, delete everything and get from svn again but I cannot understand why the repeater in the following is null on page_load. I know this is going to be a headslapping moment. Help me out? Markup: <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="GalleryControl.ascx.cs" Inherits="Site.UserControls.GalleryControl" %> <asp:Repeater ID="rptGalleries" runat="server"> <HeaderTemplate><ul></HeaderTemplate> <ItemTemplate> <li>wqe</li> </ItemTemplate> <FooterTemplate></ul></FooterTemplate> </asp:Repeater> Code behind public partial class GalleryControl : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { rptGalleries.DataSource = new[] {1, 2, 3, 4, 5}; rptGalleries.DataBind(); } } Why is my repeater null? What the F is going on?

    Read the article

  • Using POST or SESSION to capture data

    - by Karinne
    Hi all! I'm currently working on web application using VB in ASP.NET. Right now I have 1 page with panels that we are using to show/hide depending on the flow. When the user first comes in, he/she is presented with a gridview containing a list of clients. Then the user, clicks a link from a row and is presented a form where he/she can update the clients' info. Originally, I had a HYPERLINKFIELD that put the clientId in the url, then I'd grab the url and do the code appropriately <asp:HyperLinkField Text='<%$ Resources:Resource, ManageClient %>' DataNavigateUrlFields="CLIENT_ID" DataNavigateUrlFormatString="~/clients/manage.aspx?clientId={0}" /> Now, I'm rethinking that and wondering if it's better to use SESSIONs to grab the clientID via this instead <asp:TemplateField Visible="false"><ItemTemplate><asp:Label runat="server" ID="hidClientId" Text='<%# Bind("CLIENT_ID")%>' Visible="false" /></ItemTemplate></asp:TemplateField> <asp:ButtonField Text='<%$ Resources:Resource, ManageClient %>' CommandName="Manage" /> Or use the POST method, which I'm not sure how it works in .NET (but I've used it in PHP) Any help would be greatly appreciated.

    Read the article

  • How do I initialize the controls in an InsertItemTemplate?

    - by Slauma
    I have - for instance - an asp:FormView which supports Read, Insert, Update, Delete and is bound to a DataSource: <asp:FormView ID="FormView1" runat="server" DataSourceID="ObjectDataSource1" > <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("MyText") %>' /> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("MyText") %>' /> </EditItemTemplate> <InsertItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("MyText") %>' /> </InsertItemTemplate> </asp:FormView> If I am in Read-Mode or Edit-Mode the control is initialized with the property MyText of the current object which is bound to the FormView. But when I go to Insert-Mode I do not have a "current object" (FormView1.DataItem is indeed null) and the controls are empty. If I want to have my TextBox control initialized with a specific value how can I do that? In which event can I hook in to set default values to the controls in the InsertItemTemplate? Especially I have in mind using an ObjectDataSource. I was expecting that the InsertItemTemplate is initialized with a business object which underlies my ObjectDataSource and which is created by the ASP.NET framework simply by using its default constructor when the InsertItemTemplate gets activated. In the default constructor I would init the class members to the default values I'd like to have in my controls of the InsertItemTemplate. But unfortunately that's not the case: No "default" object is created and bound to the FormView. So it seems I have to initialize all controls separately or to create the default object manually and bind it to the InsertItemTemplate of the FormView. But how and where can I do that? Thanks in advance!

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >