Click here to Skip to main content
15,893,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using C#,asp.net,server 2005 and visual studio 2005

my gridview design looks like this:


FIRST_COLUMN| SECOND_COLUMN| THIRD_COLUMN| FOURTH_COLUMN| FIFTH_COLUMN|
------------ ------------- ------------ ------------- ------------
TEXTBOX1 | DROPDOWNLIST | TEXTBOX2 | TEXTBOX3 | TEXTBOX4|

Gridview contains one row and 5 columns.

now how to get the value of each column without using any of the event...

i have to get the value when the button is clicked..

plz help me..

regards
karan
Posted

1 solution

try this

C#
protected void Button1_Click(object sender, EventArgs e)
{
    // Iterates through the rows of the GridView control
    foreach (GridViewRow row in GridView1.Rows)
    {
        // Selects the text from the TextBox
        // which is inside the GridView control
        string textBoxText = _
          ((TextBox)row.FindControl("TextBox1")).Text;
      
        // Selects the text from the DropDownList
        // which is inside the GridView control
        string dropDownListText = ((DropDownList)
           row.FindControl("DropDownList1")).SelectedItem.Value;
       
    }
}
 
Share this answer
 
Comments
karan joshua 10-May-11 1:42am    
oh thank u...

always helpful ...

and always code working correctly

thank u very much SIR....

once again thank u...
Mahendra.p25 10-May-11 1:43am    
No need to say thanks try to understand each and every line of code so that u will not face problem in future good Luck

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