Click here to Skip to main content
15,894,337 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai this is kiran .. i have a one problem .. in my application i use gridview control in that i use template field ..but i will find out the textbox in the edititemtemplate itss not find .. but i find label correctly .. pls tell me the solution ..
Posted
Comments
thatraja 28-May-10 1:03am    
Post the code you tried, so that we can solve your issue.
nagendrathecoder 28-May-10 1:05am    
Your issue is not very clear to me, can you please post the code and explain what you needed.

Kiran,

There could be one silly mistake - missing 'runat="server"' attribute for your textbox.
 
Share this answer
 
This article Editable GridView in ASP.NET 2.0 and this article Accessing the different controls inside a GridView control should answer your question. They are very good articles, please check them out. I used them to solve my problems when working with GridView.
 
Share this answer
 
refer

Accessing the different controls inside a GridView control[^]


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;
        Response.Write(textBoxText);
        // Selects the text from the DropDownList
        // which is inside the GridView control
        string dropDownListText = ((DropDownList)
           row.FindControl("DropDownList1")).SelectedItem.Value;
        Response.Write(dropDownListText);
        // Selects items from the ListBox
        // which is inside the GridView control
        ListBox myListBox = (ListBox)row.FindControl("ListBox1");

        foreach(ListItem selectedItem in myListBox.Items)
        {
            // Checks if the item in the ListBox is selected or not
            if (selectedItem.Selected)
            {
                // Print the value of the item if its selected
                Response.Write(selectedItem.Value);
            }
        }
    }
 
Share this answer
 
Comments
kiran kumar reddy 31-May-10 5:14am    
Reason for my vote of 1
ths is very nice example ..its helpful me ..

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