行更改(数据绑定)时,从网格视图的显示值显示到文本框中 [英] Display Values from grid view in to text boxes when row changing (Data binding)

查看:91
本文介绍了行更改(数据绑定)时,从网格视图的显示值显示到文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中有一个网格视图,我的数据表中有5列
网格视图显示所有这些数据.当用户单击每一行时,我希望在5个文本框中显示特定的值.我做了一些代码,但只显示了1次.当用户选择另一行时,它显示错误.在这里需要帮助我的代码

 私有 无效 kryptonDataGridView1_CellContentClick(对象发​​件人,DataGridViewCellEventArgs e)
        {
            字符串 cn = Connection.ReadPath();
            SqlConnection con =  SqlConnection(cn);
            SqlCommand com =  SqlCommand(" ,骗局);
            DataSet ds =  DataSet();
            SqlDataAdapter广告=  SqlDataAdapter(com);
            ad.Fill(ds," );

            kryptonTextBox1.DataBindings.Add(" ,ds, " );
kryptonTextBox1.DataBindings.Add(" ,ds, " );
        } 

解决方案

检查您的文本框是否设置了任何自动回发属性,然后将其默认设置为false.您可以通过Java脚本来实现.我已经回答了同样的问题.我正在提供链接

如何将girdview数据绑定到文本框 [ ^ ]

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

 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");
        }

解决方案

check your textbox have any auto postback property set, then make default as false..


you can do it by java script. i have answered same question. i am giving the link

How to bind girdview data to textboxes[^]


这篇关于行更改(数据绑定)时,从网格视图的显示值显示到文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆