如何在单击特定行后获取GridView TextBox列数据。 [英] How to Get GridView TextBox Column Data after clicking on a specific row.

查看:81
本文介绍了如何在单击特定行后获取GridView TextBox列数据。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个文本框列的gridview,需要获取所选行的第一列数据并将其显示在标签中。

我正在做什么....

  protected   void  GridCall_SelectedIndexChanged(对象发​​件人,EventArgs e)
{
尝试
{
Label complain_no =(标签)GridCall.SelectedRow.FindControl( txtCallID);
string strQry = 选择抱怨_日期,抱怨_no ,pno,问题,pcno,状态,来自call_log其中complain_no =' + complain_no + ' ;
GlobalDs = GlobalConectionClass.ExecuteDataSet(strQry);
if (GlobalDs.Tables [ 0 ]。Rows.Count > 0
{
lblPno.Text = string .Format( {0},GlobalDs.Tables [ 0 ]。DefaultView [ 0 ] [ PNO]);

}
GlobalDs.Dispose();
}
catch (例外情况)
{
ClientScript.RegisterStartupScript( this .GetType(), 102 < script> alert('Error Occured。'+' + ex.Message + ')< / script>);
}
}





使用什么事件???

解决方案

您可以尝试使用相同的事件



Textbox complain_no =(Textbox)GridCall.SelectedRow.FindControl(txtCallID) ;



Yourlabel.text = complain_no.Text;



甚至



string complain_no = GridView1.SelectedRow.Cells [0] .Text; // 0表示第一列



Yourlabel.Text = complain_no;

i hv gridview with multiple textbox columns and need to get the data of first column of selected row and show it in a label.
what i m doing is....

protected void GridCall_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            Label complain_no =(Label) GridCall.SelectedRow.FindControl("txtCallID");
            string strQry = "Select complain_date,complain_no,pno, problem, pcno, status, from call_log where complain_no = '" + complain_no + "'";
            GlobalDs = GlobalConectionClass.ExecuteDataSet(strQry);
            if (GlobalDs.Tables[0].Rows.Count > 0)
            {
                lblPno.Text = string.Format("{0}", GlobalDs.Tables[0].DefaultView[0]["pno"]);
               
            }
            GlobalDs.Dispose();
        }
        catch(Exception ex)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "102", "<script> alert('Error Occured.'+'" + ex.Message + "')</script>");
        }
    }



what event to used???

解决方案

You can try like in the same event you have used

Textbox complain_no =(Textbox) GridCall.SelectedRow.FindControl("txtCallID");

Yourlabel.text = complain_no.Text ;

or even

string complain_no = GridView1.SelectedRow.Cells[0].Text;// 0 for the first column

Yourlabel.Text = complain_no;


这篇关于如何在单击特定行后获取GridView TextBox列数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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