Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
    }
}


Any idea what am I missing? thanx:confused:
Posted

1 solution

use

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

In you code you are assigning a control to the textbox text.
 
Share this answer
 
v3
Comments
AmbiguousName 2-Mar-11 8:58am    
In you code you are assigning a control to the textbox text.
I dont know what you mean by this but just changing the code according to your suggestion solved my problem. Please explain what you said by giving a line of code as im new to asp.net. thnx
Albin Abel 2-Mar-11 9:09am    
row.Cells[2] is referring the Field Cell control. row.Cells[2].ToString() gives the name of the control
rajivpande86 2-Mar-11 18:41pm    
My 5 !!
Sometimes just a sharp observation helps..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900