嗨,如何在文本框中显示网格中的选定值? [英] hi how to display selected values from grid in text box ?
本文介绍了嗨,如何在文本框中显示网格中的选定值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi如何在文本框中显示网格中的选定值..
我的aspx中包含两个日期文本框和一个普通文本框.
当我从网格视图单击时,我想在文本框中显示.
我尝试了许多来自google的示例,但没有显示?
hi how to display selected values from grid in text box..
in my aspx contains two date textboxes and one normal textbox.
when i click from grid view i want to show in textbox.
i tried many examples from google but its not displaying?
推荐答案
在行命令事件中,如果您在网格视图中使用BoundField,则必须使用以下命令: br/>
In the row command event if you are using BoundFields in the grid view you have to use the following:
TextBox1.Text = GridView1.Rows[value].Cells[0].Text;
TextBox2.Text = GridView1.Rows[value].Cells[2].Text;
同样,您必须将单元格数据分配给文本框.
如果将TemplateField与控件一起使用,则必须使用以下内容.
like wise you have to assign cell data to the text boxes.
If you are using TemplateField with controls you have to use the following.
TextBox txtBox = GridView1.Rows[value].FindControl("<HereContrlID1>");
if(txtBox != null)
{
TextBox1.Text = txtBox.Text;
}
txtBox = GridView1.Rows[value].FindControl("<HereContrlID2>");
if(txtBox != null)
{
TextBox2.Text = txtBox.Text;
}
就像明智的做法,您必须对其他文本框或下拉字段进行操作.
like wise you have to do for other text boxes or drop down fields.
在Gridview单元格中添加带有功能的javascript onclick事件,该函数将传递该单元格值,
并在函数中将该单元格值设置为textbox
1.在RowDatabound事件中
In Gridview cell add javascript onclick event with a fuction which will pass that cell value,
and within the function you will set that cell value to textbox
1.in RowDatabound event
LinkButton lnkB = ( LinkButton)e.Row.FindControl("lnkDate");
lnkB.Attribute.Add("click","JSFuntion('+lnkB.Text+"'))"
in JSFuntion(val)
{
document.getElementById(<%=txt.ClientID%>).value=val;
}
这篇关于嗨,如何在文本框中显示网格中的选定值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文