Click here to Skip to main content
15,914,419 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have update panel in which I have grid view.Grid view contain image button with command argument when I click on imagebutton I set rowcommand event in which I fill the some textbox which is present on same page but outside of grid view means like edit functionality. I have return all code. it execute correctly but data is not showing into textbox even alert also not showing so I need help?

What I have tried:

I have write code into rowcommand but it not working also I have check with image button click event still not showing data.
Posted
Updated 29-Mar-18 0:58am
Comments
F-ES Sitecore 29-Mar-18 7:21am    
When you trigger an update panel update it can only change components in that update panel. If you have a component outside the panel that you want to update then you need to put that component in an update panel too and set the update modes of the panels to "Always" so that updating one also updates the other.

1 solution

gridview
make sure you using correct command name..
<asp:TemplateField HeaderStyle-Font-Bold="false" HeaderStyle-Font-Size="12px"
   HeaderText="Edit"
   ItemStyle-Font-Bold="false" ItemStyle-Font-
   Size="12px" ItemStyle-Width="20px">
   <ItemTemplate>
   <asp:ImageButton ID="Editimg" CausesValidation="false" runat="server"
   CommandName="Edit" Height="20px" ImageUrl="~/Images/edit.png"
                                          Width="20px" />
                                  </ItemTemplate>
                                  <HeaderStyle Font-Bold="False" Font-Size="12px" />
                                  <ItemStyle Font-Bold="False" Font-Size="12px"
                                           Width="20px" />
                              </asp:TemplateField>


code behind...
   // if you have set visible false then you have to use this.. maincat.Columns[1].Visible = true;
            if (e.CommandName == "Edit")
            {
                ImageButton Editimg = (ImageButton)e.CommandSource;

                GridViewRow row = (GridViewRow)Editimg.NamingContainer;


                    
                    TextBox1.Text = row.Cells[1].Text;
                    TextBox2.Text = row.Cells[2].Text;
                   // how many textboxes you use here
                   

//if you have any conditon use this   if (row.Cells[3].Text == "No")
                  //  {
                 //       chkActive.Checked = false;
                 //   }
                 //   else
                 //   {
                 //       chkActive.Checked = true;
                 //   }


               //atlast you can use this if you have visible false in any row.     maincat.Columns[1].Visible = false;

                    
            }
 
Share this answer
 
Comments
Member 12893295 30-Mar-18 14:26pm    
should i put the code into rowcommand event or any other event? becoz i have done with row commmand whatever you gave but is not working. i put my code below:
<asp:ScriptManager ID="ScriptManager1" runat="server">

<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Always" runat="server">
<contenttemplate>
<asp:GridView ID="grdUpdate" runat="server" BackColor="#DEBA84" BorderColor="#DEBA84"
BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2"
OnRowCommand="grdUpdate_RowCommand" OnRowDataBound="grdUpdate_RowDataBound">
<columns>
<asp:TemplateField HeaderText="Edit">
<itemtemplate>
<asp:ImageButton ID="lbledit" runat="server" CommandArgument='<%#Eval("ID") %>'
CommandName="Edit" CausesValidation="false"
ImageUrl="~/Images/RIDER LOGO.ico" Width="20px" Height="20px" />


<asp:TemplateField HeaderText="ID">
<itemtemplate>
<asp:Label ID="lblID" runat="server" Text='<%#Eval("ID") %>'>


<asp:TemplateField HeaderText="Name">
<itemtemplate>
<asp:Label ID="lblName" runat="server" Text='<%#Eval("Name") %>'>


<asp:TemplateField HeaderText="Age">
<itemtemplate>
<asp:Label ID="lblAge" runat="server" Text='<%#Eval("Age") %>'>



<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />




ID
<asp:TextBox ID="txtid" runat="server">
Name
<asp:TextBox ID="txtName" runat="server">
Age
<asp:TextBox ID="txtAge" runat="server">




--------------------------------------------------------
protected void grdUpdate_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
if (e.CommandName == "Edit")
{
ImageButton img = (ImageButton)e.CommandSource;
GridViewRow row = (GridViewRow)img.NamingContainer;

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