Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Gridview
When i click on the button of grid view then that row will be hide........it never show again in gridview.....
aspx
 
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
           CellPadding="3" ForeColor="#333333" GridLines="None" 
     CellSpacing="4" Width="92%"  Visible="False" BorderColor="#DEBA84" 
           BackColor="#DEBA84" BorderStyle="None" BorderWidth="1px" AllowPaging="True" 
           onpageindexchanging="GridView1_PageIndexChanging" DataKeyNames="P_id" 
           onrowdatabound="GridView1_RowDataBound" 
        >
     <columns>
        <asp:BoundField HeaderText="Username" DataField="Uname" />
        <asp:BoundField HeaderText="Product name" DataField="Product_name" />
        <asp:BoundField HeaderText="Product Quantity" DataField="Product_quan"  />
        <asp:BoundField HeaderText="Delivery Date (MM/DD/YYYY)" DataField="Delivery_date" />
        <asp:BoundField HeaderText="Extend Date (MM/DD/YYYY)" DataField="Extend_date" />
        <asp:BoundField HeaderText="Product Information" DataField="check_bit"  />
        <asp:TemplateField>
        <itemtemplate>
        <asp:LinkButton ID="click" runat="server" Text="Dispatch">
        </itemtemplate>
         <asp:TemplateField>
        <itemtemplate>
          <asp:LinkButton ID="lnkbtn" runat="server" Text="InvDisp" ForeColor="Blue">
        </itemtemplate>
    </columns>
        <footerstyle backcolor="#990000" font-bold="True" forecolor="White" />
        <pagerstyle backcolor="#FFCC66" forecolor="#333333" horizontalalign="Center" />
        <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="White" BorderColor="#738A9C"  />
        <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" Height="30%" />
        <alternatingrowstyle backcolor="White" />
        
.cs
 
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DataRowView row = (DataRowView)e.Row.DataItem;
                string eid = ((LinkButton)e.Row.FindControl("click")).Text;
            
                string lnkbtn = ((LinkButton)e.Row.FindControl("lnkbtn")).Text;
                string param = "challan_report.aspx?P_id=" + row["P_id"] + "&Uname=" + row["Uname"];
                ((LinkButton)e.Row.FindControl("click")).Attributes.Add("OnClick", "window.open('" + param + "','PopupWindow','toolbar=no, location=no, directories=no,titlebar=no, status=no, menubar=no,resizable=NO,scrollbars=NO,copyhistory=no,width=600,height=600,top=20,left=20')");
                string caram = "Invoice.aspx?P_id=" + row["P_id"] + "&Uname=" + row["Uname"];
                ((LinkButton)e.Row.FindControl("lnkbtn")).Attributes.Add("OnClick", "window.open('" + caram + "','PopupWindow','toolbar=no, location=no, directories=no,titlebar=no, status=no, menubar=no,resizable=NO,scrollbars=NO,copyhistory=no,width=600,height=600,top=20,left=20')");
                
            }
 

        }
Posted 2-Jan-13 20:28pm
Edited 6-Jan-13 2:02am
v5
Comments
Prasad_Kulkarni at 3-Jan-13 1:31am
   
Can you post some code snippets. It's quite unclear for me. Please elaborate some more.
Rashid Choudhary at 3-Jan-13 1:57am
   
aspx
 
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CellPadding="3" ForeColor="#333333" GridLines="None"
CellSpacing="4" Width="92%" Visible="False" BorderColor="#DEBA84"
BackColor="#DEBA84" BorderStyle="None" BorderWidth="1px" AllowPaging="True"
onpageindexchanging="GridView1_PageIndexChanging" DataKeyNames="P_id"
onrowdatabound="GridView1_RowDataBound"
>

<asp:BoundField HeaderText="Username" DataField="Uname" />
<asp:BoundField HeaderText="Product name" DataField="Product_name" />
<asp:BoundField HeaderText="Product Quantity" DataField="Product_quan" />
<asp:BoundField HeaderText="Delivery Date (MM/DD/YYYY)" DataField="Delivery_date" />
<asp:BoundField HeaderText="Extend Date (MM/DD/YYYY)" DataField="Extend_date" />
<asp:BoundField HeaderText="Product Information" DataField="check_bit" />
<asp:TemplateField>

<asp:LinkButton ID="click" runat="server" Text="Dispatch">

<asp:TemplateField>

<asp:LinkButton ID="lnkbtn" runat="server" Text="InvDisp" ForeColor="Blue">



<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="White" BorderColor="#738A9C" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" Height="30%" />


 

.cs
 

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView row = (DataRowView)e.Row.DataItem;
string eid = ((LinkButton)e.Row.FindControl("click")).Text;

string lnkbtn = ((LinkButton)e.Row.FindControl("lnkbtn")).Text;
string param = "challan_report.aspx?P_id=" + row["P_id"] + "&Uname=" + row["Uname"];
((LinkButton)e.Row.FindControl("click")).Attributes.Add("OnClick", "window.open('" + param + "','PopupWindow','toolbar=no, location=no, directories=no,titlebar=no, status=no, menubar=no,resizable=NO,scrollbars=NO,copyhistory=no,width=600,height=600,top=20,left=20')");
string caram = "Invoice.aspx?P_id=" + row["P_id"] + "&Uname=" + row["Uname"];
((LinkButton)e.Row.FindControl("lnkbtn")).Attributes.Add("OnClick", "window.open('" + caram + "','PopupWindow','toolbar=no, location=no, directories=no,titlebar=no, status=no, menubar=no,resizable=NO,scrollbars=NO,copyhistory=no,width=600,height=600,top=20,left=20')");

}
 

}
Turbo_23 at 3-Jan-13 1:50am
   
Post your code Rashid.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This question makes no sense. Post some code so we know what you mean. you can hide rows in the UI with javascript, but the best way to remove rows, is to remove them from the data source.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Add another column as bit type in database table by which your grid view bind.
and update value of that column on button click event.
bind gridview as
select *from table1 where status=false.
 
bind gridview after updateing record.as
 
gridview1.DataBind();
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 380
1 OriginalGriff 230
2 DamithSL 200
3 Zoltán Zörgő 149
4 BillWoodruff 120
0 OriginalGriff 7,610
1 DamithSL 5,559
2 Sergey Alexandrovich Kryukov 5,324
3 Maciej Los 4,961
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100