如何将gridview单元格值传递给用户控件文本框 [英] How To Pass the gridview cells values to user control text boxs
问题描述
我想将网格视图单元格数据传递到用户控件文本框.
假设像
这样的gridview单元格数据
i = gridview1.currentrow.index
obj.pid = gridview1.rows [i] .value.tostring();
我使用属性传递了这些值.
用户控件有文本框,(用户控件为另一种形式),我写了
之类的属性
公共字符串pid
{
设置{textbox1.text = vaalue;}
get {return textbox1.text}
}
我创建了用户控件运行时并添加了该控件,但带有空文本框
为什么?
请帮助我
谢谢
venkat
Hi,
I want to Pass Grid view cells data to user control text boxes.
Suppose the gridview cell data like
i=gridview1.currentrow.index
obj.pid=gridview1.rows[i].value.tostring();
I passed these values using properties.
The user control have text boxes, (user control is in another form) and i wrote property like
public string pid
{
set{textbox1.text=vaalue;}
get{return textbox1.text}
}
i created user control run time and added but come with empty textboxes
why?
please help me
thanks
venkat
推荐答案
txtboxFName.Text = DgvEmployee.Rows [DgvEmployee.SelectedRows [0] .Index] .Cells [0] .Value.ToString();
txtboxFName是文本框的名称,而DgvEmployee是datagrid视图的名称.
使用它,它会将第0行的第0个单元格的值提供给文本框.
:)
txtboxFName.Text = DgvEmployee.Rows[DgvEmployee.SelectedRows[0].Index].Cells[0].Value.ToString();
txtboxFName is the name of textbox and DgvEmployee is the name of datagrid view.
use it, it gives the value of 0th cell of 0th row to the textbox .
:)
//In user control
private int m_minValue;
public int MinValue
{
get
{
return m_minValue;
}
set
{
m_minValue = value;
}
}
//In Page
MinValue = gridview1.currentrow.index;
//Pass the MinValue value to textbox.
这篇关于如何将gridview单元格值传递给用户控件文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!