burhanahmed92 0 Light Poster

I have a multicolumn listview. There are three button Add, delete and Updata. List is working fine, it add, delete and update list data. But i want to save every row inside listview when i click save button. Bellow is my XAML.

<TextBox Canvas.Left="12" Canvas.Top="12" Height="23" Name="textBox1" 
        Width="120" TextChanged="textBox1_TextChanged" KeyDown="textBox1_KeyDown" 
        GotFocus="textBox1_GotFocus" />
    <TextBox Canvas.Left="146" Canvas.Top="12" Height="23" Name="textBox2" 
        Width="120" TextChanged="textBox2_TextChanged" GotFocus="textBox2_GotFocus" 
        KeyDown="textBox2_KeyDown" />
    <ListView Canvas.Left="12" Canvas.Top="68" Height="183" Name="listView1" 
        Width="253" SelectionChanged="listView1_SelectionChanged" 
        SelectionMode="Single">
        <ListView.View>
            <GridView>
                <GridViewColumn Header="Col1" Width="150" 
                    DisplayMemberBinding="{Binding Col1}"></GridViewColumn>
                <GridViewColumn Header="Col1" Width="50" 
                    DisplayMemberBinding="{Binding Col2}"></GridViewColumn>
            </GridView>
        </ListView.View>
    </ListView>
    <Button Name="addButton" Canvas.Left="122" Canvas.Top="41" Height="21" 
        Width="69" Click="addButton_Click" IsDefault="True">Add</Button>
    <Button Name="removeButton" Canvas.Left="197" Canvas.Top="41" Height="21" 
        Width="69" Click="removeButton_Click">Remove</Button>
    <Button Name="okButton" Canvas.Left="274" Canvas.Top="13" Content="OK" 
        Height="22" Width="74" Click="okButton_Click" />
    <Button Name="closeButton" Canvas.Left="274" Canvas.Top="44" Content="Close" 
        Height="22" Width="74" Click="closeButton_Click" />
    <Button Name="saveButton" Canvas.Left="274" Canvas.Top="75" Content="Save" 
        Height="22" Width="74" Click="saveButton_Click" />

My add method is like

private void addButton_Click(object sender, RoutedEventArgs e)
{
    setDataChanged(true);
    AddRow();
}

and other methods are also like these. I want a save method which get every row from listview and add each row to database. I am using SQL Server with WPF C#

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.