Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Every One,
I am stuck with a problem, and the problem is i have created a grid view and there are 4 columns in it, what i want is when i click on Book Meeting Time column it should generate a session variable by storing user id.

Best Regards,
Thank You.

What I have tried:

Here Is The Code For GridView

ASP.NET
<asp:GridView ID="GridView1" runat="server" ShowHeaderWhenEmpty="true" EmptyDataText="No Records Found." OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
            <columns>
<asp:TemplateField HeaderText="Book Meeting Time">
                    <ItemTemplate>
                    <a href="" id="clickme" onclick="LinkWith">Click Here</a>
                    </ItemTemplate>
                    
                </asp:TemplateField>
            </columns>
        </asp:GridView>



Here is my jquery code.
JavaScript
function myPartialView() {
            $(document).on('click', '#clickme', function () {
window.open("BookMeetingTimePopUp.aspx", "PopupWindow", "width=600,height=600,scrollbars=yes,resizable=no");
            })
        }



and Here Is my server side code

C#
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Database db = new Database();
            Session["USERID"] = GridView1.Rows[0].Cells[2];
        }


This is how my grid view looks like on clicking "Click Me" i want to create a session.
Book Meeting Time	FirstName	LastName	UserId	EmailAddress
Click Here	        Daniyal	        Farhan	        19000   daniyalfarhan@xyz.com
Click Here	        Daniyal	        Ahmed	        19200	daniyal@xyz.com
Posted
Updated 1-Jan-20 22:05pm
v3

1 solution

Hello, use it like this without jquery.

ASP.NET
<asp:GridView ID="GridView1" runat="server" ShowHeaderWhenEmpty="true" EmptyDataText="No Records Found." OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
<columns>
<asp:CommandField ShowSelectButton="true" ButtonType="Link" SelectText="Click Here" HeaderText="Book Meeting Time" />
</columns>
        </asp:GridView>


Also you can add this attribute to GridView and a select button will be added automatically.
AutoGenerateSelectButton="True"
 
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