使用GridView的OnRowCommand获取列值 [英] Getting Column Value Using OnRowCommand of GridView

查看:103
本文介绍了使用GridView的OnRowCommand获取列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好....即时通讯在网格的每一行中使用一个小按钮.现在,我有一个小文本框,我想在其中显示一行中的特定列值,我可以使用 GridView . 现在,我得到了这一行,但无法在文本框中显示它.这就是我想要做的.

hello guys.... im using a small button in each of the row on the Grid. Now I have a small text box in which I want to show a particular column value from a row, which I retreived using OnRowCommand function of GridView. Now I get this row but unable to show it in text box. Here is what I am trying to do.

protected void OnRowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == ("Show"))
    {
        int index = Convert.ToInt32(e.CommandArgument); //this will get rowid from gridview
        GridViewRow row = gridCalls.Rows[index];
        txt1.Text = row.Cells[2].ToString(); // second column in the sql server database
    }
}



知道我想念什么吗? thanx:confused:



Any idea what am I missing? thanx:confused:

推荐答案

use

txt1.Text = row.Cells[2].Text;

在您的代码中,您正在为文本框文本分配控件.
use

txt1.Text = row.Cells[2].Text;

In you code you are assigning a control to the textbox text.


这篇关于使用GridView的OnRowCommand获取列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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