C# Data Binding & GridView Help Needed plz!

Ranhiru

Member
Feb 2, 2007
6,438
42
0
Inside FIREFOX
I have a form with data bindings. and i use a BindingManagerBase to travel through the records


Code:
SqlConnection con = Global.Con;
            con.Open();
            da = new SqlDataAdapter("SELECT * FROM Customer", con);
            mcb = new SqlCommandBuilder(da);

            da.Fill(ds, "Customer");

            txtCustomerFName.DataBindings.Add(new Binding("Text", ds.Tables["Customer"], "Cus_FName"));
            txtCustomerLName.DataBindings.Add(new Binding("Text", ds.Tables["Customer"], "Cus_LName"));
            txtCustomerAddress.DataBindings.Add(new Binding("Text", ds.Tables["Customer"], "Cus_Address"));
            txtCustomerEmail.DataBindings.Add(new Binding("Text", ds.Tables["Customer"], "Cus_Email"));
            txtCustomerRegDate.DataBindings.Add(new Binding("Value", ds.Tables["Customer"], "Reg_Date"));
            txtCustomerLoyalty.DataBindings.Add(new Binding("Text", ds.Tables["Customer"], "Loyalty"));
    
           bm = this.BindingContext[ds.Tables["Customer"]];


And then i use bm.Position +=1 and bm.Position -=1 to travel through it.

Code:
private void cmdBack_Click(object sender, EventArgs e)
        {
            

            if (bm.Position == 0)
                MessageBox.Show("Reached beginning of list!", "Cannot go further!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            else
                bm.Position -= 1;
            
        }

        private void cmdNext_Click(object sender, EventArgs e)
        {
            
           
            if (bm.Position == (bm.Count - 1))
                MessageBox.Show("Reached end of list!", "Cannot go further!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            else
            bm.Position += 1;
        }
Anyway i use a DataView and DataView.RowFilter to search and display the results in the DataGridView which is in a seperate form. And once the search results are returned i want to set the current position in the before form to whatever row is selected in the Data Grid View.

Code:
private void CustomerSearch_Load(object sender, EventArgs e)
        {

            SqlConnection con = Global.Con;
            SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Customer", con);
            da.Fill(ds, "Customer");
            dv.Table = ds.Tables[0];


            DGV1.DataSource = dv;



            
            
            


        }

        private void txtSearchString_TextChanged(object sender, EventArgs e)
        {

            dv.RowFilter = "Cus_FName LIKE '*" + txtSearchString.Text + "*' OR Cus_LName LIKE '*" + txtSearchString.Text+ "*' OR Cus_Address LIKE '*" + txtSearchString.Text + "*' OR Cus_Email LIKE '*" + txtSearchString.Text + "*'";



        }


Now if the user selects a row returned from the searching, i want set the bm.Position (which is in another form but i can take the searching the same form as well) to whatever the row selected on the DataGridView.

I hope you get the problem. Please ask me if this is not clear. How can i do that?
 

digitaldjs

Member
Aug 11, 2007
926
36
0
machn bindingmanager gen oka thikak difficult mehema karala balapan

user select karapu row eke ID eka ganin ita passe aluth query ekak hadapan ex: "SELECT * FROM Customer WHERE ID=Userselectedrowid" ita passe form eka fill karala balanna
 

Ranhiru

Member
Feb 2, 2007
6,438
42
0
Inside FIREFOX
digitaldjs said:
machn bindingmanager gen oka thikak difficult mehema karala balapan

user select karapu row eke ID eka ganin ita passe aluth query ekak hadapan ex: "SELECT * FROM Customer WHERE ID=Userselectedrowid" ita passe form eka fill karala balanna

ok thanx machan! Ill try that :) :)
 

Ranhiru

Member
Feb 2, 2007
6,438
42
0
Inside FIREFOX
coolshano said:
wow, C is cool...

For heavens sake please stop replying to threads that you have no idea what its abt! And its C# and not C!!! please just dont try to increase your post count by posting ela ela or hmmmm or just bluff! Try to increase your post count by telling something useful! :D