Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8473875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:28:26+00:00 2026-06-10T17:28:26+00:00

I have a datagrid that’s declared with the following: <DataGrid AutoGenerateColumns=True Margin=10,174,12,35 Name=dataGridArchiveQueue Visibility=Visible

  • 0

I have a datagrid that’s declared with the following:

<DataGrid AutoGenerateColumns="True" Margin="10,174,12,35" Name="dataGridArchiveQueue" Visibility="Visible" 
AlternatingRowBackground="#01000000" 
BorderBrush="#FF688CAF" 
HorizontalGridLinesBrush="#37000000" 
VerticalGridLinesBrush="#37000000" 
CanUserAddRows="False" 
CanUserDeleteRows="False" 
IsReadOnly="True" 
SelectedItem="{Binding SelectedItemArchiveGrid}" Grid.ColumnSpan="2">
     <DataGrid.Resources>
          <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
                                                         Color="LightBlue" />
     </DataGrid.Resources>
</DataGrid>

I populate this datagrid with the following:

public DataView ArchiveEvents(string status, string sourceLibrary, string destinationLibrary)
        {
            var queryString = sourceLibrary == destinationLibrary &&
                                 (!String.IsNullOrEmpty(sourceLibrary) && !String.IsNullOrEmpty(destinationLibrary))
                                    ? @"SELECT  archive_queue_id AS 'ID',
                                                [status] AS 'Status' , 
                                                source_site AS 'Source Site', 
                                                source_url AS 'Source Library', 
                                                destination_site AS 'Destination Site' ,
                                                destination_url AS 'Destination Library',
                                                CASE WHEN recurring_job = 1
                                                THEN 'Yes'
                                                ELSE 'No'
                                                END AS 'Recurring Job' ,
                                                isnull(cast(last_run AS varchar(30)), 'Never') AS 'Last Run' ,
                                                isnull(cast(created_by AS varchar(30)), 'Unknown') AS 'Created By' ,
                                                created_date AS 'Created Date' ,
                                                isnull(last_modified_by, '') AS 'Last Modified By' ,
                                                isnull(cast(last_modified_date AS varchar(30)),'') AS 'Last Modified Date'
                                        FROM    marlin.archive_queue
                                        WHERE   upper([status]) LIKE '%' + upper(@status) + '%'
                                                AND upper(source_url) LIKE '%' + upper(@source_library) + '%'
                                                or upper(destination_url) LIKE '%' + upper(@destination_library) + '%'"
                                    : @"SELECT  archive_queue_id AS 'ID',
                                                [status] AS 'Status' , 
                                                source_site AS 'Source Site', 
                                                source_url AS 'Source Library', 
                                                destination_site AS 'Destination Site' ,
                                                destination_url AS 'Destination Library',
                                                CASE WHEN recurring_job = 1
                                                THEN 'Yes'
                                                ELSE 'No'
                                                END AS 'Recurring Job' ,
                                                isnull(cast(last_run AS varchar(30)), 'Never') AS 'Last Run' ,
                                                isnull(cast(created_by AS varchar(30)), 'Unknown') AS 'Created By' ,
                                                created_date AS 'Created Date' ,
                                                isnull(last_modified_by, '') AS 'Last Modified By' ,
                                                isnull(cast(last_modified_date AS varchar(30)),'') AS 'Last Modified Date'
                                        FROM    marlin.archive_queue
                                        WHERE   upper([status]) LIKE '%' + upper(@status) + '%'
                                                AND upper(source_url) LIKE '%' + upper(@source_library) + '%'
                                                AND upper(destination_url) LIKE '%' + upper(@destination_library) + '%'";


            using (var connection = new SqlConnection(GetConnectionString()))
            {
                using (var cmd = new SqlCommand(queryString, connection))
                {
                    connection.Open();

                    cmd.Parameters.AddWithValue("status", status != "Anything" ? status : "");
                    cmd.Parameters.AddWithValue("source_library", sourceLibrary != "Anything" ? sourceLibrary : "");
                    cmd.Parameters.AddWithValue("destination_library", destinationLibrary != "Anything" ? destinationLibrary : "");


                    using (var reader = cmd.ExecuteReader())
                    {
                        var dt = new DataTable();
                        dt.Load(reader);

                        connection.Close();
                        return dt.DefaultView;
                    }
                }
            }
        }

I’m now trying to get the contents of a selected row so I can edit or delete it via a button. To do this, I have the following property:

public DataView SelectedItemArchiveGrid { get; set; }

But have no idea how to access this property to get details of the currently selected item.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:28:28+00:00Added an answer on June 10, 2026 at 5:28 pm

    You need to change the binding property type of SelectedItemArchiveGrid from DataView to DataRowView and need to use RelativeSource on XAML for binding

    XAML

    SelectedItem="{Binding DataContext.SelectedItemArchiveGrid, RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}}"
    

    C#

    private DataRowView _selectedItemArchiveGrid;
    public DataRowView SelectedItemArchiveGrid
    {
        get
        {
            return _selectedItemArchiveGrid;
        }
        set
        {
            _selectedItemArchiveGrid = value;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGrid that has AutoGenerateColumns=True. I'm binding that DataGrid to a collection
I have a DataGrid that is setup like this: <DataGrid AutoGenerateColumns=True GridLinesVisibility=Horizontal IsReadOnly=True ItemsSource={Binding
I have a DataGrid that I have bound to a property: <cd:DataGrid Name=myDataGrid ItemsSource={Binding
I have a DataGrid that represents layers - each row is an image on
I have a datagrid that is filled with a dataset from an SQL query.
I have a datagrid that I want to add a button/s to at runtime.
I have a DataGrid that needs to show a gradient background on mouseover of
I have a DataGrid that is showing some data via a PagedCollectionView with one
I have a datagrid that I have filled with data from a sql database.
I have a datagrid that is editable. I was wondering if it's possible to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.