在windows应用程序的gridview中从组合框获取值 [英] Get value from combobox in gridview in windows application

查看:75
本文介绍了在windows应用程序的gridview中从组合框获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将学生信息保存在数据库中。有一些文本框和一个带有组合框和文本框的网格视图。在gridview之外有一个sumbit按钮,我想,当用户点击组合框的峰值按钮值(选定值)和文本框保存在数据库中,但我无法获得组合框和gridviev文本框的价值



i我正在使用.net 4.0,windows应用程序用c#

i want to save student information in database. there are some textbox and one gridview with a combobox and textbox. there is a sumbit button outside of gridview, i want, when user click to summit button value of combobox(selected values) and textbox save in database, but i can not get value of combobox and textbox of gridviev

i am using .net 4.0, windows application with c#

推荐答案

你好,



假设我有一个datagridview,有两列。其中一个是DatagridviewCombobox列(位于第0位),另一个是TextBox列(位于第1位)。



现在,如果我想从外面获取这些值如果用户动态地添加行,我必须进行循环。



Hello ,

suppose i have a datagridview , there are two columns . one of them is DatagridviewCombobox column (at 0th position) and another one is TextBox column(at 1st position).

now , if i want to get those value from outside of a button , i have to make loop if user dynamically can add rows .

private void btn_Click(object sender, EventArgs e)
{
  for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
    {
     string cmbvalue = dataGridView1.Rows[i].Cells[0].Value.ToString(); 
     //for combobox column
     string txtvalue = dataGridView1.Rows[i].Cells[1].Value.ToString();
     //for textbox column

     //other codes to save those value in database  

    }
        
}



谢谢


thanks


通过gridview c#.net
update datagridview column value by selected combobox in gridview c#.net

中的选定组合框更新datagridview列值


这篇关于在windows应用程序的gridview中从组合框获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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