Click here to Skip to main content
15,889,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When i click on the button of grid view then that row will be hide........it never show again in gridview.....
aspx

C#
<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

C#
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
Updated 6-Jan-13 1:02am
v5
Comments
Prasad_Kulkarni 3-Jan-13 1:31am    
Can you post some code snippets. It's quite unclear for me. Please elaborate some more.
Rashid Choudhary 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"
>
<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">

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


<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')");

}


}
[no name] 3-Jan-13 1:50am    
Post your code Rashid.

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.
 
Share this answer
 
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
SQL
select *from table1 where status=false.


bind gridview after updateing record.as

C#
gridview1.DataBind();
 
Share this answer
 

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