ASP.NET - how to enable panel ,when i click on Gridview Linkbutton(View button is placed in Grid)

Asked By aileni giri on 29-Jun-12 06:58 AM
Earn up to 10 extra points for answering this tough question.
<table >
<tr>
<td>
<asp:GridView  ID="gridview1" runat="server">
  <asp:TemplateField HeaderText="View">
         <ItemTemplate>
         <asp:LinkButton ID="lnkview"  Text="View" runat="server"></asp:LinkButton>
         </ItemTemplate>
       </asp:TemplateField>
         
       <asp:TemplateField HeaderText="Doc's">
         <ItemTemplate>
         <asp:LinkButton ID="lnkdocs"  Text="Doc's" runat="server"></asp:LinkButton>
         </ItemTemplate>
       </asp:TemplateField>
       </Columns>
       </asp:GridView>
</td>
</tr>
<tr>
<td>

</td>
</tr>
dipa ahuja replied to aileni giri on 29-Jun-12 07:46 AM
Add linkButton in itemTEmplate:
 
<ItemTemplate>
<asp:LinkButton ID="lnkd" CommandName="Select" runat="server" Text="Select" />
</ItemTemplate>
 
Then implement the RowCommand EVent:
 
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
  if (e.CommandName == "Select")
  {
    //Enable panel
   panel1.Enable= true;
  }
}
 
 
C D replied to aileni giri on 29-Jun-12 08:19 AM

Hi Frndz,

 

Functionality:  GridView Link button click enable Panel

 

 

To achieve this task,

 

First you need to Added OnClick event of Link button

 

            <asp:LinkButton ID="lnkview" Text="View" runat="server" OnClick="lnkView_Click"></asp:LinkButton>

 

 

After added Server Side onclick Event

 

protected void lnkView_Click(Object sender, EventArgs e)

    {

    }

 

If  Panel OutSide GridView then Use

 

protected void lnkView_Click(Object sender, EventArgs e)

    {

      pnlView.Enabled = true;

    }

 

 

If  Panel Inside GridView then Use

 

protected void lnkView_Click(Object sender, EventArgs e)

    {

      LinkButton lnk = sender as LinkButton;

      GridViewRow grow = (GridViewRow)lnk.NamingContainer;

      Panel pnlInsideGridView = (Panel)grow.FindControl("pnlInsideGridView");

      pnlInsideGridView.Enabled = true;

  

    }

 

 

 

 

 

Full Logic with Inside Panel and Outside Gridview Panel Enabled:

 

Aspx PAGE

 

 

<asp:TemplateField HeaderText="View">

          <ItemTemplate>

            <asp:LinkButton ID="lnkview" Text="View" runat="server" OnClick="lnkView_Click"></asp:LinkButton>

          </ItemTemplate>

        </asp:TemplateField>

InSide

 

        <asp:TemplateField HeaderText="PanelView">

          <ItemTemplate>

            <asp:Panel ID="pnlInsideGridView" runat="server" Enabled="false">

              <asp:TextBox ID="txtViewName" runat="server"></asp:TextBox>

            </asp:Panel>

          </ItemTemplate>

        </asp:TemplateField>

 

 

OutSide

<asp:Panel ID="pnlView" runat="server" Enabled="false">

      <asp:TextBox ID="txtViewName" runat="server"></asp:TextBox>

    </asp:Panel>

 

CS PAGE

protected void lnkView_Click(Object sender, EventArgs e)

    {

      LinkButton lnk = sender as LinkButton;

      GridViewRow grow = (GridViewRow)lnk.NamingContainer;

      Panel pnlInsideGridView = (Panel)grow.FindControl("pnlInsideGridView");

      pnlInsideGridView.Enabled = true;

      pnlView.Enabled = true;

    }

 

 

Hope this helpful!

Thanks

 

 

 

Jitendra Faye replied to aileni giri on 29-Jun-12 08:20 AM
You can complete this task using client side code also-

use this code-

 <script type="text/javascript">
    function enable() {
        document.getElementById('<%=panel1.ClientID%>').disabled = false;
        return false;
      }
 </script>



          <ItemTemplate>
            <asp:LinkButton  ID="lnk" runat="server" Text="Enable" OnClientClick ="return enable();"/>
          </ItemTemplate>


Try this and let me know.
RAJASEKHAR RAJENDRAN replied to aileni giri on 29-Jun-12 08:40 AM
hi giri,

Hope the below link solves.

http://stackoverflow.com/questions/8798639/how-to-get-the-clicked-linkbutton-text-in-gridview-to-a-label-in-popup-panel 



Thanks & Regards,
Rajasekhar.R
help
Hi all, I am using linkbutton inside the gridview. and when i click the linkbutton i want to go to the next url with the query string of dropdown list that is in ouside of gridview. please anybody tell the coding? below is my design coding: <asp:GridView ID = "GridView2" runat = "server" AllowPaging = "True" AutoGenerateColumns = "False" DataKeyField = "CompanyName" EmptyDataText = "No List Found" Height Image ID = "imgPhoto" runat = "server" ImageUrl = '. . / <%#Eval("Picturefile") %> ' Width = "120px" Height = "105px" / > < / td> <td> <asp:LinkButton ID = "lbtnNext" runat = "server" Text = '<%#Eval("HotelName") %> ' OnClick = "lbtnNext_Click" / > <%- -<a href = 'DetailedView.aspx?hn = <%#Eval
hi frds how can i create an excel sheet from gridview using javascript when i click on linkbutton in item template in gridview HI Here is the complete code to Export GridView to Excel: using System; using System.Data; using System.Configuration; using System.Collections; using System GetType().GetProperty( "Text" ).GetValue(control, null ); control.Parent.Controls.Remove(control); } } } } public static void ExportGridView(GridView gridView, string fileName, ExportType exportType) { const string m_Http_Attachment = "attachment;filename = " ; const string m_Http_Content = "content-disposition" ; HttpResponse
I have this gridview. . nw on click of the "editform" button, i want to redirect it to another page with the parameter of visitno. my code is as below. . :: <asp:GridView ID = "GridView1" runat = "server" AutoGenerateColumns = "False" CellPadding = "4" ForeColor = "#333333" GridLines = "None" Width = "1000px"> <AlternatingRowStyle HeaderText = "FromCity" / > <asp:BoundField DataField = "ToCity" HeaderText = "ToCity" / > <asp:TemplateField HeaderText = "Edit Form"> <ItemTemplate> <asp:LinkButton ID = "linkeditform" runat = "server" PostBackUrl = " "> EditForm< / asp:LinkButton> < / ItemTemplate> < / asp:TemplateField> <asp:TemplateField HeaderText = "Print Form"> <ItemTemplate> <asp:LinkButton ID = "linkprint" runat = "server"> PrintForm< / asp:LinkButton> < / ItemTemplate> < / asp:TemplateField> < / Columns> <EditRowStyle BackColor = "#999999" / > <FooterStyle BackColor = "#5D7B9D" Font-Bold = "True" ForeColor = "White
link button inside gridvieww not firing javascript will u pls explain detailly ? show ur code to solve ur issue. . . To identify linkbutton in GridView Use FindControl to find the linkbutton LinkButton LnkAdd = (LinkButton)e.Row.FindControl("LnkAdd"); Now add JavaScript OnClick Function LnkAdd .Attributes.Add( "onclick" , "show();" ); See function show() { alert( "In link button click" ); } If you want to bind client function with LinkButton Control, which is in GridView, then use following code- < asp : GridView ID = "GridDetails" runat = "server" AutoGenerateColumns = "false" > < Columns > < asp : TemplateField
hai, I want to get the datakeynames value from gridview on link button click event I tried but iam unable get the id. This is DataSource = dt1; GridView2.DataBind(); } } hie i tried ur code but iam geting error like The GridView 'GridView1' fired event RowEditing which wasn't handled. i write like this <asp:TemplateField> <ItemTemplate> <asp:LinkButton runat = "server" ID = "lnkselect" CommandArgument = '<% #Eval("PersonID") %> ' Text = "Select" Commandname = "Edit" OnClick = "SelectedChange"> Select< / asp LinkButton> < / ItemTemplate> < / asp:TemplateField> int rowIndex = int.Parse(e.CommandArgument.ToString()); string val = this.GridView1.DataKeys dt1 = ds.Tables[0]; GridView2.DataSource = dt1; GridView2.DataBind(); ModalPopupExtender1.Show(); Try this way: < asp : LinkButton ID = "lnkEdit" CommandName = "Edit" Text = "Edit" runat = "server" / > protected void GridView1_RowCommand( object sender, GridViewCommandEventArgs e) { if (e.CommandName = = "Edit" ) { GridViewRow row = ( GridViewRow )((( LinkButton )e.CommandSource).NamingContainer); int id = int .Parse(GridView1.DataKeys[row.RowIndex].ToString()); / / other statements } } hie
Hi , I am using VS2005 , C#, asp.net and sql 2005. i want to implement horizontal scrolling in nested gridview(gridview within gridview) How to implement it ? Thanks in advance. Regards, Preejo Try putting your nested gridview code inside asp:Panel , and set scrollbar property od panel to both or horizontal <asp:Panel ID = "pGridViewContainer" runat = "server" ScrollBars = "Both"> gridview inside a panel, with the Panel control’s ‘Scrollbars’ property, you can choose vertical, horizontal ScrollBars = "Horizontal" BorderStyle = "Inset" BorderWidth = "1px" BorderColor = "Black" runat = "server" Height = "142px" Width = "350px"> <asp:GridView ID = "grdV_categories" runat = "server" AutoGenerateColumns = "False" ShowHeader = "False" DataKeyNames = "categoryid"> <Columns> <asp:TemplateField> <ItemTemplate> <table of <%# DataBinder.Eval (Container.DataItem, "CategoryName") %> :< / b> < / td> < / tr> <tr> <td> / / Nested Grid View <asp:GridView ID = "grdV_products" runat = "server" AutoGenerateColumns = "False" ShowHeader = "False"> <Columns> <asp:TemplateField> <ItemTemplate> <%# DataBinder.Eval (Container
public static void ExportDataSetToExcel( DataSet ds , string code which will be written in aspx.cs protected void lnkCustomerID_Click(object sender, EventArgs e) { LinkButton link = (LinkButton)sender; GridViewRow gv = (GridViewRow)(link.Parent.Parent); LinkButton CustomerID = (LinkButton)gv.FindControl("lnkCustomerID"); Session["customerid"] = CustomerID.Text; Response.Redirect("customer_detail.aspx"); } and here's the code of gridview's link button for your .aspx page <asp GridView ID = "GridView1" runat = "server" Width = "100%" EnableTheming = "false" AutoGenerateColumns = "false"> <Columns> <asp:TemplateField HeaderText = "Customer
I have a GridView that displays a list of contact names, email address, etc. Inside of it, I have another GridView that shows the 1 or more phone numbers for that contact and I set it to Visible = False. When I select the line (using a LinkButton) I am making the embedded GridView (phone numbers) Visible on that SelectedIndex. However, when I select a different contact in the GridView the previous contact line / row still shows their phones GridView. Where is the best place to hide this non-selected embedded GridView? Thanks. David ASP
i'm using three gridviews <gridview> <columns> <gridview> <columns> < / columns> < / gridview> <gridview> <columns> < / columns> < / gridview> < / columns> < / gridview> i ant find third gridview from parent grid pls help me Hello you can find