Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
<asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="HyperLink1" runat="server" Text="View" CommandName="Vview" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="HyperLink2" runat="server" Text="Edit" CommandName="Vedit" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="HyperLink3" runat="server" Text="Delete" CommandArgument='<%# Eval("MsID") %>'
                            CommandName="Vdelete" OnClientClick="return ConfirmOnDelete('');" />
                    </ItemTemplate>
                </asp:TemplateField>

C#
protected void Grdmilestones_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        GridViewRow gvr = (GridViewRow)((Control)e.CommandSource).NamingContainer;
        if (e.CommandName == "Vview")
        {
            Label lb = (Label)gvr.FindControl("Label1");
            sqlstr = "select MsID,Title,Description,Date,Script from Milestones";
            FillGrid();
        }
        if (e.CommandName == "Vedit")
        {
            Label lb = (Label)gvr.FindControl("Label2");
            sqlstr = "select MsID,Title,Description,Date,Script from Milestones";
            FillGrid();
        }
        if (e.CommandName == "Vdelete")
        {
            int ID = Convert.ToInt32(e.CommandArgument.ToString());
            sqlstr = "Delete Milestones where MsID=" + ID;
            con.Open();
            SqlCommand cmd = new SqlCommand(sqlstr, con);
            cmd.ExecuteNonQuery();
            con.Close();
            FillGrid();
        }
        FillGrid();
    }
Posted
Updated 3-Dec-14 21:06pm
v2
Comments
Praveen Kumar Upadhyay 4-Dec-14 3:04am    
What you want to do. Please explain in brief.
CP_vicky 4-Dec-14 3:11am    
In Grid view i am having view and Edit Link buttons. If i press view a new Popup window has to generate and should display the Grid view values.
Same like Edit also but it can be edit and change will save in to data base

Add a new aspx Page to accept the values to to display. Show this Page in Modal on click of View Link of gridview and pass Grid row value to this new Page using query string or something.

Opening Modal(another Page like Popup) is very easy in Jquery.

XML
<script language="javascript">
    $(document).ready(function() {
        tb_show("HAI","yourPage.aspx?KeepThis=true&TB_iframe=true&width=300&height=200",null);
    });
</script>


See below article. It might help you.

http://www.c-sharpcorner.com/UploadFile/9f0ae2/gridview-edit-delete-and-update-in-Asp-Net/
 
Share this answer
 
v2
Comments
CP_vicky 4-Dec-14 4:18am    
I am not having Text box to edit the fields. how to edit the Grid view fields on clicking edit link button
Praveen Kumar Upadhyay 4-Dec-14 4:42am    
Enable Edit functionality of Gridview to Edit the details right there. This will enable Textbox/Dropdown etc controls to edit the values.
CP_vicky 4-Dec-14 4:54am    
Can you please explain in step by step. its not working here
Praveen Kumar Upadhyay 4-Dec-14 5:02am    
I have improved my solution checkout the link.
You can do this by using ModalPopupExtender control from the ASP.NET AJAX Control Toolkit .

I have an article (and source code) where I am using ModalPopupExtender. Here is the link: Advanced ASPX GridView Pagination and Data Entities[^]
 
Share this answer
 
C#
if (e.CommandName == "Select")
       {
           mp1.Show();
       }

C#



XML
<asp:HiddenField ID="hf" runat="server" />
        <cc1:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panel1" TargetControlID="hf"
            CancelControlID="btnClose" BackgroundCssClass="modalBackground">
        </cc1:ModalPopupExtender>
        <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" align="center">

HTML

HTML

 
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