Click here to Skip to main content
15,922,584 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a grid view in my project i have 5 columns in my data table
grid view displays these all data. i wan to display particular values in to 5 textboxes when user click each row . i have done some code but it shwws only 1 time. when user select another row it show error. need help here my code

C#
 private void kryptonDataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string cn = Connection.ReadPath();
            SqlConnection con = new SqlConnection(cn);
            SqlCommand com = new SqlCommand("select Name  from Rice", con);
            DataSet ds = new DataSet();
            SqlDataAdapter ad = new SqlDataAdapter(com);
            ad.Fill(ds,"Rice");

            kryptonTextBox1.DataBindings.Add("Text", ds, "Rice.Name");
kryptonTextBox1.DataBindings.Add("Text", ds, "Rice.Price");
        }
Posted
Updated 2-Jun-12 1:41am
v2

check your textbox have any auto postback property set, then make default as false..
 
Share this answer
 
you can do it by java script. i have answered same question. i am giving the link

How to bind girdview data to textboxes[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900