Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I used

GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
 TextBox txtcmt = (TextBox)row.FindControl("txtComment");

string c=txtcmt.text


but txtcmt returns null value
plz help....
Thanks
Posted
Updated 21-May-12 22:23pm
v2
Comments
Technoses 22-May-12 5:11am    
where you want to use textbox and why
I know that this is a old question. But I just want to know the status of the issue.

Is it solved? Else I can help you.

In Gridview RowCommand,
C#
protected void gvScripts_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "IFullView")
    {
        int index = 0;
        string lstrVal = "";

        if (e.CommandArgument != "")
        {
            index = Convert.ToInt32(e.CommandArgument);
            lstrVal = gvScripts.DataKeys[index].Value.ToString().Trim();
        }
    }
}

And in .aspx,

I have a column with ImageButton. So, when I click this button, I need to get the value of a column (of SelectedRow), which is given in DataKeyNames in GridView,
HTML
<asp:GridView ID="gvScripts" runat="server" AutoGenerateColumns="False" OnRowCommand="gvScripts_RowCommand" DataKeyNames="DL_RECID">

    <Columns>
        <asp:TemplateField HeaderText="" HeaderStyle-HorizontalAlign="center" HeaderStyle-Width="30px">
            <ItemStyle CssClass="HRLineCDL" Wrap="true" HorizontalAlign="Center"></ItemStyle>
            <ItemTemplate>
                <asp:ImageButton ID="btnIFullView" AlternateText="Full View" runat="server" CommandName="IFullView"
                    CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" />
            </ItemTemplate>
    
        </asp:TemplateField>
    </Columns>
 
Share this answer
 
v2
 
Share this answer
 
Hello,

Please refer - How to populate textbox with value of gridview control?[^]

It may be helpful for you.


[Edit member="Tadit"]
Link text added to reflect the article title.
[/Edit]
 
Share this answer
 
v2
Refer - how to get values from textbox which is in gridview Footer c#?[^]


[Edit member="Tadit"]
Link text added to reflect the article title.
[/Edit]
 
Share this answer
 
v2
Comments
madhan2008 22-May-12 5:39am    
not help ful

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