Search Results

Search found 493 results on 20 pages for 'databind'.

Page 1/20 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • how to get xml html after transpose and databind()

    - by rlee923
    Hi. I have some code that uses xsl and xml. The Xml control is on the design page. The xml control id is xmlApplication The xmlstring is generated and xsl has the format with all the tables and cells etc. Here is a part of thecode of a page which generates the final product which shows the xml in a certain format. xmlApplication.Document = xmlDoc; xmlApplication.Transform = transApp; xmlApplication.DataBind(); I am guessing after xmlApplication.Databind(), xmlApplication will be converted into something that can be put inside . Is it possible to grab as a string? Please let me know if I have a wrong idea abut this. Thanks a lot.

    Read the article

  • C# WPF DataBind boolean

    - by jtdangelo
    I have been using this website to learn a lot about C# for a while, but this is my first time posting a question. I look forward to hearing back from some of the seasoned C# veterans! I have been working on a C# 4.0 WPF project and need to figure out how to databind a boolean value. I have a reference to my Application.Current object in a window. My "App" object contains a boolean field called "Downloaded" that is true if the user has downloaded information from a web service. I need to databind a textbox's IsEnabled field to this Downloaded value. Any tips? Here is what I have come up with so far. (Any useful links to better learn WPF XAML are greatly appreciated!) C# Code: class MainWindow : Window { ... private App MyApp = App.Current as App; ... } XAML: <TextBox ... IsEnabled="{Binding Source=MyApp, Path=Downloaded}" /> James

    Read the article

  • Winform ListView databind

    - by Manu
    Hi, I have a Listview that uses databind. I set the DataSource property to a binding source. All works fine. The problem is that I need to have a column that is not databinded and contains only buttons that have the same handler for click event. To accomplish this I tried to add a subitem that is a button for each ListViewItem after InitializeComponent but doesn't work, nothing is displayed. Also I set the list view column type to Control. If I add elements to ListView and isn't databinded that the buttons appear. So it will be a great help for me to know if buttons could be displayed in column that is not databinded when the listview uses databinding for rest of columns. Thanks!

    Read the article

  • Databind listbox

    - by JaSk
    I'm pretty new to asp net 2.0 programming and I was wondering how can I add an "all" item to a listbox, so I can filter my results by a specific criteria ( from a database ) or display all the results. Thanks in advance

    Read the article

  • Shows how to use AutocompleteExtender to populate subjects and databind quotations via Entity Framew

    This article will focus on a database of famous quotations that I"ve pared down to a downloadable size for a demo, and how to wire up the AJAX Toolkit autocomplete extender to a textbox that is used to typeahead a Subject. When the ClientItemSelected event fires, the Display button Click is invoked, and this causes an EF query to display the matching quotes in a DataList.  read moreBy Peter BrombergDid you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Shows how to use AutocompleteExtender to populate subjects and databind quotations via Entity Framew

    This article will focus on a database of famous quotations that I"ve pared down to a downloadable size for a demo, and how to wire up the AJAX Toolkit autocomplete extender to a textbox that is used to typeahead a Subject. When the ClientItemSelected event fires, the Display button Click is invoked, and this causes an EF query to display the matching quotes in a DataList.  read moreBy Peter BrombergDid you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • DataTable won't DataBind with a DataTable.NewRow()

    - by David
    Is DataRow.NewRow() insufficient as the only row in a DataTable? I would expect this to work, but it doesn't. It's near the end of my Page_Load inside my If(!Postback) block. gridCPCP is GridView DataTable dt = new DataTable(); dt.Columns.Add("ID", int.MinValue.GetType()); dt.Columns.Add("Code", string.Empty.GetType()); dt.Columns.Add("Date", DateTime.MinValue.GetType()); dt.Columns.Add("Date2", DateTime.MinValue.GetType()); dt.Columns.Add("Filename", string.Empty.GetType()); //code to add rows if (dt.Rows.Count > 0) { gridCPCP.DataSource = dt; gridCPCP.DataBind(); } else { dt.Rows.Add(dt.NewRow()); gridCPCP.DataSource = dt; gridCPCP.DataBind(); //EXCEPTION int TotalColumns = gridCPCP.Rows[0].Cells.Count; gridCPCP.Rows[0].Cells.Clear(); gridCPCP.Rows[0].Cells.Add(new TableCell()); gridCPCP.Rows[0].Cells[0].ColumnSpan = TotalColumns; gridCPCP.Rows[0].Cells[0].Text = "No Record Found"; } The exception throws on gridCPCP.DataBind() and only when execution reaches the else block. If there were rows added above via dt.Rows.Add(new object[] { ... } binding works. System.ArgumentOutOfRangeException: Length cannot be less than zero. Parameter name: length

    Read the article

  • WPF databind Image.Source in MVVM

    - by BrettRobi
    I'm using MVVM and am trying to databind the Source property of Image to my ViewModel in such a way that I can change the icon on the fly. What is the best pattern to follow for this? I still have the flexibility to change my ViewModel to suit, but I don't know where to start in either the xaml or ViewModel. To be clear, I don't want my ViewModel to know about the specific images (that's for the View to know), just the state that triggers different images. For now I have just two states, lets say Red and Green. Should I create an Enum property or a bool? And then how do I databind to switch the image source?

    Read the article

  • Asp.Net GridView in DropDownList in-line databind

    - by oraclee
    Hi All; <asp:GridView ID="GridView1" runat="server"> <Columns> <asp:TemplateField> <EditItemTemplate> <asp:DropDownList ID="DropDownList1" runat="server"> </asp:DropDownList> </EditItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { } How To Make GridView1_RowEditing event in DataBind DropDownList1 ? I need Editing databind dropdownlist pls Help Thank You.

    Read the article

  • Databind' is not a member of 'CrystalDecisions.Windows.Forms.CrystalReportViewer'

    - by Selom
    Hi, ive being trying to cope with this problem but still. I need your help. Im having the following error message: Databind' is not a member of 'CrystalDecisions.Windows.Forms.CrystalReportViewer' in my code: Dim rpt As New CrystalReport1() Dim da As New SQLiteDataAdapter Dim ds As New presbydbDataSet 'Dim cmd As New SQLiteCommand("SELECT personal_details.fn, training.training_level FROM personal_details INNER JOIN training ON Staff_ID WHERE personal_details.staff_ID='" + detailsFrm.Label13.Text + "'", conn) Dim cmd As New SQLiteCommand("SELECT * FROM personal_details WHERE personal_details.staff_ID='" + detailsFrm.Label13.Text + "'; SELECT * FROM training WHERE training.staff_ID='" + detailsFrm.Label13.Text + "'", conn) cmd.ExecuteNonQuery() da.SelectCommand = cmd da.Fill(ds) rpt.SetDataSource(ds) rpt.Subreports.Item("personal_detailsRpt").SetDataSource(ds.Tables("personal_details")) rpt.Subreports.Item("trainingRpt").SetDataSource(ds.Tables("training")) CrystalReportViewer1.ReportSource = rpt CrystalReportViewer1.DataBind() Im using vb.net and these are the imports Im using: Imports System.Data.SQLite Imports System.Configuration Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.ReportAppServer Please how can I get rid of this error? Thanks for answering

    Read the article

  • Databind Parent/Child relation with Mysql

    - by e2k
    What is the best way to databind parent/child relations? Lets say I have two simple objects: Parent with the following properties, ParentId, Name and Childs and Child with the following properties, ChildId, Name and Parent. I want to write a repository using MySql for this but is failing when I bind both Childs and Parent properties, I have only been able to bind either the Childs property of parent or the Parent property och Child or else I would get a infinite loop. Thinking of it the preferable solution would be to only bind this properties when requested. If I use Linq to sql i would be able to write Parent.Childs[0].Parent.Name but how should I accomplish this with my own repository and with MySql, could anyone point me in the right direction? Looking at the Linq 2 sql generated classes they use EntitySet<Child and EntityRef<Parent could this be used with Mysql? I had a thought of using my IChildRepository in the Parent object and let the Public IEnumerable Childs databind the childs but it seems not right? Best regards E2k

    Read the article

  • When to databind data-bound controls?

    - by sanjuro
    Hi, i have little dilemma, i often use data-bound controls such as Gridview in conjunction with ObjectDataSource. But i have two possible options when can i bind data to Gridview. The first is that i set datasourceid of gridview in aspx file and databind occurs in a moment before PreRender event occurs or i can set datasource in Page_Load event and databinding occurs immediately, something like this: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { testGridView.DataSource = testObjectDataSource.Select(); testGridView.DataBind(); } } I think that in second approach i have more control above databinding. But how it is in real programming life? Which of the above two options is commonly used? Or is there some third option how can i bind data to data-bound control? Thanks for your opinions from real-life experiences.

    Read the article

  • DataBind and Postback

    - by Michael La Voie
    This is a general how does DataBind work questions... I have a simple page with a GridView that is bound (in the aspx code) to an ObjectDataSource. I can look in the Select() function called by the ObjectDataSource to see that it is called on the initial load and on every post back. I have some logic that happens on post backs that will affect the GridView's data, and I want to call GridView.DataBind() later on in the post back, after I've made some changes. Is there a way to prevent the automatic rebinding that happens on each post back? Does this mean I can't use an ObjectDataSource for this control?

    Read the article

  • databind the Source property of the WebBrowser in WPF

    - by Russ
    Does anyone know how to databind the .Source property of the WebBrowser in WPF ( 3.5SP1 )? I have a listview that I want to have a small WebBrowser on the left, and content on the right, and to databind the source of each WebBrowser with the URI in each object bound to the list item. This is what I have as a proof of concept so far, but the "<WebBrowser Source="{Binding Path=WebAddress}"" does not compile. <DataTemplate x:Key="dealerLocatorLayout" DataType="DealerLocatorAddress"> <StackPanel Orientation="Horizontal"> <!--Web Control Here--> <WebBrowser Source="{Binding Path=WebAddress}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" Width="300" Height="200" /> <StackPanel Orientation="Vertical"> <StackPanel Orientation="Horizontal"> <Label Content="{Binding Path=CompanyName}" FontWeight="Bold" Foreground="Blue" /> <TextBox Text="{Binding Path=DisplayName}" FontWeight="Bold" /> </StackPanel> <TextBox Text="{Binding Path=Street[0]}" /> <TextBox Text="{Binding Path=Street[1]}" /> <TextBox Text="{Binding Path=PhoneNumber}"/> <TextBox Text="{Binding Path=FaxNumber}"/> <TextBox Text="{Binding Path=Email}"/> <TextBox Text="{Binding Path=WebAddress}"/> </StackPanel> </StackPanel> </DataTemplate>

    Read the article

  • Value cannot be null.Parameter name: key when databind in ASP.NET

    - by Yongwei Xing
    Hi all I am triing to bind the data to a listbox from sql server then got the error "Value cannot be null.Parameter name: key" sqlCommand = "SELECT [Country] FROM [tbl_LookupCountry] where [Country] IS NOT NULL"; SqlConnection sqlConCountry = new SqlConnection(connectString); SqlCommand sqlCommCountry = new SqlCommand(); sqlCommCountry.Connection = sqlConCountry; sqlCommCountry.CommandType = System.Data.CommandType.Text; sqlCommCountry.CommandText = sqlCommand; sqlCommCountry.CommandTimeout = 300; sqlConCountry.Open(); reader = sqlCommCountry.ExecuteReader(); ddlCountry.DataSource = reader; ddlCountry.DataBind(); sqlConCountry.Close(); Does anyone meet this problem before?

    Read the article

  • gridview databind

    - by frenchie
    Hi, I'm doing a gridview with an object datasource: List<MyObject> TheSource = a linq query At some point, I have MyGridview.DataSource = TheSource; MyGridview.Databind(); and an OnRowDataBound event handler that's tied to the databinding. In that event handler, how do you make column 2 contain 2 objects from TheSource. For instance, in the TheSource, there is a variable for FirstName and another one for LastName. Column 2 needs to contain both the first and last name in the same cell. Thanks.

    Read the article

  • WinForms databind to collection property (such as count)

    - by Ornus
    I want to databind to a collection property, such as Count. in general, when I data bind I specify data member for the object property in the collection, not for the actual properties collection itself exposes. for example, I have a list of custom objects. I show them in datagridview. but I also want to show their total count using a separate label. is there a way to do this through databinding? I imagine that somehow I need to force PropertyManager to be used, instead of CurrentyManager? I get the following exception. Notice that DataSource is collection and has TotalValue property. System.ArgumentException: Cannot bind to the property or column TotalValue on the DataSource. Parameter name: dataMember at System.Windows.Forms.BindToObject.CheckBinding() at System.Windows.Forms.Binding.SetListManager(BindingManagerBase bindingManagerBase) at System.Windows.Forms.ListManagerBindingsCollection.AddCore(Binding dataBinding) at System.Windows.Forms.BindingsCollection.Add(Binding binding) at System.Windows.Forms.BindingContext.UpdateBinding(BindingContext newBindingContext, Binding binding) at System.Windows.Forms.Binding.SetBindableComponent(IBindableComponent value) at System.Windows.Forms.ControlBindingsCollection.AddCore(Binding dataBinding) at System.Windows.Forms.BindingsCollection.Add(Binding binding)

    Read the article

  • LINQ compiled query DataBind issue

    - by Brian
    Hello All, I have a pretty extensive reporting page that uses LINQ. There is one main function that returns an IQueryable object. I then further filter / aggregate the returned query depending on the report the user needs. I changed this function to a compiled query, it worked great, and the speed increase was astonishing. The only problem comes when i want to databind the results. I am databinding to a standard asp.net GridView and it works fine, no problems. I am also databinding to an asp.net chart control, this is where my page is throwing an error. this works well: GridView gv = new GridView(); gv.DataSource = gridSource; But this does not: Series s1 = new Series("Series One"); s1.Points.DataBindXY(gridSource, "Month", gridSource, "Success"); The error i receive is this: System.NotSupportedException Specified method is not supported When i look into my gridSource var at run time i see this using a typical linq query: SELECT [t33].[value2] AS [Year], [t33].[value22] AS [Month], [t33].[value3] AS [Calls]...... I see this after i change the query to compiled: {System.Linq.OrderedEnumerable<<>f__AnonymousType15<string,int,int,int,int,int,int,int>,string>} This is obviously the reason why the databindxy is no longer working, but i am not sure how to get around it. Any help would be appreciated! Thanks

    Read the article

  • Trouble with LINQ databind to GridView and RowDataBound

    - by Michael
    Greetings all, I am working on redesigning my personal Web site using VS 2008 and have chosen to use LINQ to create by data-access layer. Part of my site will be a little app to help manage my budget better. My first LINQ query does successfully execute and display in a GridView, but when I try to use a RowDataBound event to work with the results and refine them a bit, I get the error: The type or namespace name 'var' could not be found (are you missing a using directive or an assembly reference?) This interesting part is, if I just try to put in a var s = "s"; anywhere else in the same file, I get the same error too. If I go to other files in the web project, var s = "s"; compiles fine. Here is the LINQ Query call: public static IQueryable pubGetRecentTransactions(int param_accountid) { clsDataContext db; db = new clsDataContext(); var query = from d in db.tblMoneyTransactions join p in db.tblMoneyTransactions on d.iParentTransID equals p.iTransID into dp from p in dp.DefaultIfEmpty() where d.iAccountID == param_accountid orderby d.dtTransDate descending, d.iTransID ascending select new { d.iTransID, d.dtTransDate, sTransDesc = p != null ? p.sTransDesc : d.sTransDesc, d.sTransMemo, d.mTransAmt, d.iCheckNum, d.iParentTransID, d.iReconciled, d.bIsTransfer }; return query; } protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { this.prvLoadData(); } } internal void prvLoadData() { prvCtlGridTransactions.DataSource = clsMoneyTransactions.pubGetRecentTransactions(2); prvCtlGridTransactions.DataBind(); } protected void prvCtlGridTransactions_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var datarow = e.Row.DataItem; var s = "s"; e.Row.Cells[0].Text = datarow.dtTransDate.ToShortDateString(); e.Row.Cells[1].Text = datarow.sTransDesc; e.Row.Cells[2].Text = datarow.mTransAmt.ToString("c"); e.Row.Cells[3].Text = datarow.iReconciled.ToString(); }//end if }//end RowDataBound My googling to date hasn't found a good answer, so I turn it over to this trusted community. I appreciate your time in assisting me.

    Read the article

  • Databind a datagrid header combobox from ViewModel

    - by Mike
    I've got a Datagrid with a column defined as this: <Custom:DataGridTextColumn HeaderStyle="{StaticResource ComboBoxHeader}" Width="Auto" Header="Type" Binding="{Binding Path=Type}" IsReadOnly="True" /> The ComboBoxHeader style is defined in a resource dictionary as this: <Style x:Key="ComboBoxHeader" TargetType="{x:Type my:DataGridColumnHeader}"> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type my:DataGridColumnHeader}"> <ControlTemplate.Resources> <Storyboard x:Key="ShowFilterControl"> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="filterComboBox" Storyboard.TargetProperty="(UIElement.Visibility)"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/> <DiscreteObjectKeyFrame KeyTime="00:00:00.5000000" Value="{x:Static Visibility.Visible}"/> </ObjectAnimationUsingKeyFrames> <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="filterComboBox" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"> <SplineColorKeyFrame KeyTime="00:00:00" Value="Transparent"/> <SplineColorKeyFrame KeyTime="00:00:00.5000000" Value="White"/> </ColorAnimationUsingKeyFrames> </Storyboard> <Storyboard x:Key="HideFilterControl"> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="filterComboBox" Storyboard.TargetProperty="(UIElement.Visibility)"> <DiscreteObjectKeyFrame KeyTime="00:00:00.4000000" Value="{x:Static Visibility.Collapsed}"/> </ObjectAnimationUsingKeyFrames> <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="filterComboBox" Storyboard.TargetProperty="(UIElement.OpacityMask).(SolidColorBrush.Color)"> <SplineColorKeyFrame KeyTime="00:00:00" Value="Black"/> <SplineColorKeyFrame KeyTime="00:00:00.4000000" Value="#00000000"/> </ColorAnimationUsingKeyFrames> </Storyboard> </ControlTemplate.Resources> <my:DataGridHeaderBorder x:Name="dataGridHeaderBorder" Margin="0" VerticalAlignment="Top" Height="31" IsClickable="{TemplateBinding CanUserSort}" IsHovered="{TemplateBinding IsMouseOver}" IsPressed="{TemplateBinding IsPressed}" SeparatorBrush="{TemplateBinding SeparatorBrush}" SeparatorVisibility="{TemplateBinding SeparatorVisibility}" SortDirection="{TemplateBinding SortDirection}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" Grid.ColumnSpan="1"> <Grid x:Name="grid" Width="Auto" Height="Auto" RenderTransformOrigin="0.5,0.5"> <Grid.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform/> <TranslateTransform/> </TransformGroup> </Grid.RenderTransform> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}"> <ContentPresenter.Content> <MultiBinding Converter="{StaticResource headerConverter}"> <MultiBinding.Bindings> <Binding ElementName="filterComboBox" Path="Text" /> <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Content" /> </MultiBinding.Bindings> </MultiBinding> </ContentPresenter.Content> </ContentPresenter> <ComboBox ItemsSource="{Binding Path=Types}" x:Name="filterComboBox" VerticalAlignment="Center" HorizontalAlignment="Right" MinWidth="20" Height="Auto" OpacityMask="Black" Visibility="Collapsed" Text="" Grid.Column="0" Grid.ColumnSpan="1"/> </Grid> </my:DataGridHeaderBorder> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Trigger.EnterActions> <BeginStoryboard x:Name="ShowFilterControl_BeginStoryboard" Storyboard="{StaticResource ShowFilterControl}"/> <StopStoryboard BeginStoryboardName="HideFilterControl_BeginShowFilterControl"/> </Trigger.EnterActions> <Trigger.ExitActions> <BeginStoryboard x:Name="HideFilterControl_BeginShowFilterControl" Storyboard="{StaticResource HideFilterControl}"/> <StopStoryboard BeginStoryboardName="ShowFilterControl_BeginStoryboard"/> </Trigger.ExitActions> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="Background"> <Setter.Value> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF0067AD" Offset="1"/> <GradientStop Color="#FF003355" Offset="0.5"/> <GradientStop Color="#FF78A8C9" Offset="0"/> </LinearGradientBrush> </Setter.Value> </Setter> <Setter Property="Foreground" Value="White"/> <Setter Property="BorderBrush"> <Setter.Value> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#D8000000" Offset="0.664"/> <GradientStop Color="#7F003355" Offset="1"/> </LinearGradientBrush> </Setter.Value> </Setter> <Setter Property="FontWeight" Value="Bold"/> <Setter Property="BorderThickness" Value="1,1,1,0"/> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="Padding" Value="5,0"/> </Style> As you can see, I'm trying to databind the combobox's ItemsSource to Types, but this doesn't work. The list is in my ViewModel that is being applied to my page, how would I specify in this style that is in my resource dictionary that I want to bind to a source in my viewmodel.

    Read the article

  • asp.net repeater returns weird html

    - by emre
    I have a repeater that is supposed to create div tags with their onclick functions from databind. Which is like onclick='<%# "functionname('" + Eval("somestring") +"');" %>' but the single quotes ' after the js func ( and before ) , they become something like ?,= .. I don't understand what's happening. .. the full code is below <div id="dvPager"> <asp:Repeater ID="pagerSorular" runat="server"> <ItemTemplate> <div class='<%# "pageritem pagertext" + ((this.PageNumber == int.Parse(Container.DataItem.ToString())) ? " pagerselected" : "") %>' onclick='<%# "gotopage('" + this.PageName + "', " + Container.DataItem + ");" %>'> <%# Container.DataItem %> </div> </ItemTemplate> </asp:Repeater> </div> and codebehind is: public int PageNumber { get { string strPgNum = Request.QueryString["pg"] as String; if (!String.IsNullOrEmpty(strPgNum)) { int pgnum; if (int.TryParse(strPgNum, out pgnum)) { if (pgnum <= 0) { return pgnum; } else { return 1; } } else { return 1; } } else { return 1; } } } public string PageName { get { string url = Request.Url.ToString(); string[] parts = url.Split(new char[]{'/'}); return parts[parts.Length - 1]; } } public void Doldur(List<SoruGridView> sorulistesi) { gridSorular.DataSource = sorulistesi; gridSorular.DataBind(); /// PagerYap(sorulistesi); } protected void PagerYap(List<SoruGridView> sorulistesi) { List<int> numpgs = new List<int>(); int count = 1; foreach (SoruGridView sgv in sorulistesi) { numpgs.Add(count); count++; } pagerSorular.DataSource = numpgs.ToArray(); pagerSorular.DataBind(); }

    Read the article

  • Databind gridview with LINQ

    - by Anders Svensson
    I have two database tables, one for Users of a web site, containing the fields "UserID", "Name" and the foreign key "PageID". And the other with the fields "PageID" (here the primary key), and "Url". I want to be able to show the data in a gridview with data from both tables, and I'd like to do it with databinding in the aspx page. I'm not sure how to do this, though, and I can't find any good examples of this particular situation. Here's what I have so far: <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="LinqBinding._Default" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Testing LINQ </h2> <asp:GridView ID="GridView1" runat="server" DataSourceID="LinqDataSourceUsers" AutoGenerateColumns="false"> <Columns> <asp:CommandField ShowSelectButton="True" /> <asp:BoundField DataField="UserID" HeaderText="UserID" /> <asp:BoundField DataField="Name" HeaderText="Name" /> <asp:BoundField DataField="PageID" HeaderText="PageID" /> <asp:TemplateField HeaderText="Pages"> <ItemTemplate <asp:DropDownList ID="DropDownList1" DataSourceID="LinqDataSourcePages" SelectedValue='<%#Bind("PageID") %>' DataTextField="Url" DataValueField="PageID" runat="server"> </asp:DropDownList> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:LinqDataSource ID="LinqDataSourcePages" runat="server" ContextTypeName="LinqBinding.UserDataContext" EntityTypeName="" TableName="Pages"> </asp:LinqDataSource> <asp:LinqDataSource ID="LinqDataSourceUsers" runat="server" ContextTypeName="LinqBinding.UserDataContext" EntityTypeName="" TableName="Users"> </asp:LinqDataSource> </asp:Content> But this only works in so far as it gets the user table into the gridview (that's not a problem), and I get the page data into the dropdown, but here's the problem: I of course get ALL the page data in there, not just the pages for each user on each row. So how do I put some sort of "where" constraint on dropdown for each row to only show the pages for the user in that row? (Also, to be honest I'm not sure I'm getting the foreign key relationship right, because I'm not too used to working with relationships). EDIT: I think I have set up the relationship incorrectly. I keep getting the message that "Pages" doesn't exist as a property on the User object. And I guess it can't since the relationship right now is one way. So I tried to create a many-to-many relationship. Again, my database knowledge is a bit limited, but I added a so called "junction table" with the fields UserID and PageID, same as the other tables' primary keys. I wasn't able to make both of these primary keys in the junction table though (which it looked like some people had in examples I've seen...but since it wasn't possible I guessed they shouldn't be). Anyway, I created a relationship from each table and created new LINQ classes from that. But then what do I do? I set the junction table as the Linq data source, since I guessed I had to do this to access both tables, but that doesn't work. Then it complains there is no Name property on that object. So how do I access the related tables? Here's what I have now with the many-to-many relationship: <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ManyToMany._Default" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Many to many LINQ </h2> <asp:GridView ID="GridView1" runat="server" DataSourceID="LinqDataSource1" AutoGenerateColumns="false"> <Columns> <asp:CommandField ShowSelectButton="True" /> <asp:BoundField DataField="UserID" HeaderText="UserID" /> <asp:BoundField DataField="Name" HeaderText="Name" /> <asp:BoundField DataField="PageID" HeaderText="PageID" /> <asp:TemplateField HeaderText="Pages"> <ItemTemplate> <asp:DropDownList ID="DropDownList1" DataSource='<%#Eval("Pages") %>' SelectedValue='<%#Bind("PageID") %>' DataTextField="Url" DataValueField="PageID" runat="server"> </asp:DropDownList> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="ManyToMany.UserPageDataContext" EntityTypeName="" TableName="UserPages"> </asp:LinqDataSource> </asp:Content>

    Read the article

  • WPF TextBox DataBind on EnterKey press

    - by Jobi Joy
    The default DataBinding on TextBox is TwoWay and it commits the text to the Property only when TextBox lost its focus. Is there any easy XAML way exists to make the DataBinding Happens when I press Enter Key on the TextBox?. I know it is pretty easy to do in the code behind, but imagine if this textBox is inside some complex DataTemplate.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >