Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Pure VPN - Up to 27 Months
vgp
Updated:
Friday at 8:10 AM
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
May 30, 2026
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
Computers & Internet
Problems and Troubleshooting
C# Data Binding & GridView Help Needed plz!
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Ranhiru" data-source="post: 4585115" data-attributes="member: 17748"><p>I have a form with data bindings. and i use a BindingManagerBase to travel through the records</p><p></p><p> </p><p> [code]SqlConnection con = Global.Con;</p><p> con.Open();</p><p> da = new SqlDataAdapter("SELECT * FROM Customer", con);</p><p> mcb = new SqlCommandBuilder(da);</p><p></p><p> da.Fill(ds, "Customer");</p><p></p><p> txtCustomerFName.DataBindings.Add(new Binding("Text", ds.Tables["Customer"], "Cus_FName"));</p><p> txtCustomerLName.DataBindings.Add(new Binding("Text", ds.Tables["Customer"], "Cus_LName"));</p><p> txtCustomerAddress.DataBindings.Add(new Binding("Text", ds.Tables["Customer"], "Cus_Address"));</p><p> txtCustomerEmail.DataBindings.Add(new Binding("Text", ds.Tables["Customer"], "Cus_Email"));</p><p> txtCustomerRegDate.DataBindings.Add(new Binding("Value", ds.Tables["Customer"], "Reg_Date"));</p><p> txtCustomerLoyalty.DataBindings.Add(new Binding("Text", ds.Tables["Customer"], "Loyalty"));</p><p> </p><p> bm = this.BindingContext[ds.Tables["Customer"]];[/code]<span style="color: Black"></span></p><p><span style="color: Black"></span></p><p> And then i use bm.Position +=1 and bm.Position -=1 to travel through it.</p><p></p><p>[code]private void cmdBack_Click(object sender, EventArgs e)</p><p> {</p><p> </p><p></p><p> if (bm.Position == 0)</p><p> MessageBox.Show("Reached beginning of list!", "Cannot go further!", MessageBoxButtons.OK, MessageBoxIcon.Information);</p><p> else</p><p> bm.Position -= 1;</p><p> </p><p> }</p><p></p><p> private void cmdNext_Click(object sender, EventArgs e)</p><p> {</p><p> </p><p> </p><p> if (bm.Position == (bm.Count - 1))</p><p> MessageBox.Show("Reached end of list!", "Cannot go further!", MessageBoxButtons.OK, MessageBoxIcon.Information);</p><p> else</p><p> bm.Position += 1;</p><p> }[/code] </p><p> 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. </p><p></p><p>[code]private void CustomerSearch_Load(object sender, EventArgs e)</p><p> {</p><p></p><p> SqlConnection con = Global.Con;</p><p> SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Customer", con);</p><p> da.Fill(ds, "Customer");</p><p> dv.Table = ds.Tables[0];</p><p></p><p></p><p> DGV1.DataSource = dv;</p><p></p><p></p><p></p><p> </p><p> </p><p> </p><p></p><p></p><p> }</p><p></p><p> private void txtSearchString_TextChanged(object sender, EventArgs e)</p><p> {</p><p></p><p> 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 + "*'";</p><p></p><p></p><p></p><p> }[/code]<span style="color: Black"></span></p><p><span style="color: Black"></span></p><p> 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.</p><p></p><p>I hope you get the problem. Please ask me if this is not clear. How can i do that?</p></blockquote><p></p>
[QUOTE="Ranhiru, post: 4585115, member: 17748"] 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"]];[/code][COLOR=Black] [/COLOR] 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; }[/code] 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 + "*'"; }[/code][COLOR=Black] [/COLOR] 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? [/QUOTE]
Insert quotes…
Verification
Nawa warak dahaya keeyada? (Namaya wadi kireema dahaya)
Post reply
Top
Bottom