日期:2014-05-16  浏览次数:21015 次

WPF listView 的操作问题


如图,当输入条码后,ListView 中出现数据

但是,当我输入第二个条码后, ListView 只显示第二个条码的内容,第一个条码,被清空了。

listView 前台是这么写的:

 <ListView Grid.Column="1" 
                      x:Name="lsList"                      
                      Grid.RowSpan="2" 
                      Margin="10"  >
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="商品编号" Width="100"
                                        DisplayMemberBinding="{Binding Path=GoodsID}"/>
                        <GridViewColumn Header="商品名称" Width="100"
                                        DisplayMemberBinding="{Binding Path=GoodsName}"/>
                        <GridViewColumn Header="价钱" Width="50"
                                        DisplayMemberBinding="{Binding Path=Export_Price}"/>
                        <GridViewColumn Header="数量" Width="50" />
                    </GridView>
                </ListView.View>


            </ListView>


查询条码的后台,我是这么写的:

        /// <summary>
        /// 查询条码
        /// </summary>
        SqlDataAdapter sda;
        DataTable dt;
        public void SelectData(string sql)
        {
            try
     &n