That's alright. All I want to do is disable the LinkButton right after it is clicked. I know that if the user reloads the page the LinkButton is going to be enabled again. I just want to disable the LinkButton after it is clicked.
For one session you can try it. When user clicks, set a Boolean variable to true and store in session. In subsequent post backs check this value to set the enabled property of LinkButton
Kindly mark this post as "Answer", if it helped you.
frmeyer
Member
19 Points
67 Posts
Re: How to Databind ListView without enabling LinkButtons
Apr 15, 2012 10:14 AM|LINK
Unfortunately that won't work. I don't have Membership for the website.
basheerkal
Star
10672 Points
2426 Posts
Re: How to Databind ListView without enabling LinkButtons
Apr 15, 2012 02:51 PM|LINK
Then ask user to give a screename to participate in voting. But without membership You cannot control one user voting many times.
(Talk less..Work more)
frmeyer
Member
19 Points
67 Posts
Re: How to Databind ListView without enabling LinkButtons
Apr 15, 2012 04:19 PM|LINK
That's alright. All I want to do is disable the LinkButton right after it is clicked. I know that if the user reloads the page the LinkButton is going to be enabled again. I just want to disable the LinkButton after it is clicked.
basheerkal
Star
10672 Points
2426 Posts
Re: How to Databind ListView without enabling LinkButtons
Apr 15, 2012 04:28 PM|LINK
For one session you can try it. When user clicks, set a Boolean variable to true and store in session. In subsequent post backs check this value to set the enabled property of LinkButton
(Talk less..Work more)
basheerkal
Star
10672 Points
2426 Posts
Re: How to Databind ListView without enabling LinkButtons
Apr 15, 2012 05:50 PM|LINK
You may try something like this
protected void GridView1_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { if (e.CommandName == "agree") { //Code for Updating agree field Page.Session["IsChecked"] = "True" // call databinding code checkClicked(); } if (e.CommandName == "disagree" { //Code for Updating disagree field Page.Session["IsChecked"] = "True" // call databinding code checkClicked(); } } void checkClicked() { GridViewRow gvr = GridView1.Rows[0]; LinkButton Lb1 = (LinkButton)gvr.FindControl("LinkButton1"); LinkButton Lb2 = (LinkButton)gvr.FindControl("LinkButton2"); if (Page.Session["IsChecked"]!= null) { if (Page.Session["IsChecked"].ToString() == "True") { Lb1.Enabled = false; Lb2.Enabled = false; } } }(Talk less..Work more)
frmeyer
Member
19 Points
67 Posts
Re: How to Databind ListView without enabling LinkButtons
Apr 15, 2012 06:00 PM|LINK
Okay, but I'm working with a ListView. How do I find the specific "row" (in this case a ListViewItem) of the LinkButtons that have to be disabled?
basheerkal
Star
10672 Points
2426 Posts
Re: How to Databind ListView without enabling LinkButtons
Apr 15, 2012 06:35 PM|LINK
Yes, Like this.
protected void Button1_Click(object sender, EventArgs e) { LinkButton hl1 = (LinkButton)ListView1.Items[0].FindControl("LinkButton1"); hl1.Enabled = false; }(Talk less..Work more)
frmeyer
Member
19 Points
67 Posts
Re: How to Databind ListView without enabling LinkButtons
Apr 15, 2012 07:54 PM|LINK
But that only finds the first ListViewDataItem? How do I find the ListViewDataItem in which the LinkButton was clicked.
basheerkal
Star
10672 Points
2426 Posts
Re: How to Databind ListView without enabling LinkButtons
Apr 16, 2012 01:28 AM|LINK
Try to loop thru the items using item index and do what i said for each row if more rows are there.
Now tell me actually what is your project. Further info can be given only after that
(Talk less..Work more)