Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

c# DataGrid Item Get Values

[es] :: .NET :: .NET Desktop razvoj :: c# DataGrid Item Get Values

[ Pregleda: 2413 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

xxxrugby

Član broj: 16068
Poruke: 653
*.adsl.net.t-com.hr.

Sajt: www.zagreb-rugby.hr


Profil

icon c# DataGrid Item Get Values20.11.2006. u 10:10 - pre 211 meseci
Imam ovako podeseno DataTable i DataGrid

Code:

        DataTable DTDataTable = new DataTable();
        private void populate_datagrid()
        {
            // Inicijaliziraj Lokacije2.mdb Pass: xxxxxx
               string connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= Lokacije2.mdb;Jet OLEDB:Database Password=xxxxxx";
            OleDbConnection Connection = new OleDbConnection();
            Connection.ConnectionString = connection;
            Connection.Open();

            OleDbDataAdapter DADataAdapter = new OleDbDataAdapter("Select * from lok", Connection);

            OleDbCommandBuilder CBCommandBuilder = new OleDbCommandBuilder(DADataAdapter);

            // Populate DataGrid
            DADataAdapter.Fill(DTDataTable);
            Connection.Close();
        }


Filtriram s

Code:
private void search_datagrid(string search)
        {
            DataView dv = new DataView(DTDataTable);
            string btntext = this.btn_LokacijaSearch.Text ;
            if (btntext == "Lokacija")
            {
                dv.RowFilter="Lokacija like '%"+search+"%'";
            } else {
                dv.RowFilter="lan like  '%"+search+"%'";
            }
            CURHDataGrid.DataSource = dv;
        }


E sad je problem sto pri tom filteru u DataGrid ostane ono sto ja zelim. Filtriran izgled. Samo njih par.
E al kad kliknes na neki od tih filtriranih izgleda on ima krivi Index. tj. u datagrid npr. ima index 1 onaj filtriran al kad pokusam gledat s
Code:
DataView dv = (DataView) DGDataGrid.DataSource;
            int dc = DGDataGrid.CurrentCell.RowNumber;
            this.txtLokacija.Text = dv.Table.Rows [dc]["Lokacija"].ToString();

On zapravo i dalje gleda DataTAble pa mi daje krivi rezultat.

Ako ima koja sintaksa da on uzima vrijednosti iz DataGrid. Neki event handler ili nesto.

Hvala
xxxrugby: "We are all philosophers, when question is about politics!"
 
Odgovor na temu

xxxrugby

Član broj: 16068
Poruke: 653
*.adsl.net.t-com.hr.

Sajt: www.zagreb-rugby.hr


Profil

icon Re: c# DataGrid Item Get Values28.11.2006. u 10:04 - pre 211 meseci
ima'l tko kakav hint.
xxxrugby: "We are all philosophers, when question is about politics!"
 
Odgovor na temu

dusty
Predrag Glumac
Zemun, Srbija

Član broj: 15383
Poruke: 549
*.ptt.yu.

Sajt: www.mika.rs


+6 Profil

icon Re: c# DataGrid Item Get Values28.11.2006. u 10:51 - pre 211 meseci
Dont miks grandmoders and frogs
Prijatelju, ti radis sa DataGridom preko DataView-a, ostavi dataTable na miru (dv.Table.Rows ....) !

Znaci :

Code:

string s = dv[DGDataGrid.CurrentCell.RowNumber].Row["Lokacija"];

America national sport is called baseballs. It very similar to our sport, shurik, where we take dogs, shoot them in a field and then have a party.
 
Odgovor na temu

xxxrugby

Član broj: 16068
Poruke: 653
*.adsl.net.t-com.hr.

Sajt: www.zagreb-rugby.hr


Profil

icon Re: c# DataGrid Item Get Values28.11.2006. u 13:43 - pre 211 meseci
Hvala puno. Ubilo me to vec tjedan dana nisam otkrio kako.

E da sam se ucim C#. pa ono mi ide malo sporije. he hehe.
xxxrugby: "We are all philosophers, when question is about politics!"
 
Odgovor na temu

[es] :: .NET :: .NET Desktop razvoj :: c# DataGrid Item Get Values

[ Pregleda: 2413 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.