Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 20, 2012 10:39 AM by sana_sz91
Aug 17, 2012 10:03 PM|LINK
i m binding 4 diff tables to 4 diff. repeaters in following manner:
protected void Page_Load(object sender, EventArgs e)
List<int> AllowedLinks = new List<int>();
DataObj = new DAL();
dt = DataObj.GetDataTable("GetAllowedLinksForUserRole",2);
foreach (DataRow myRow in dt.Rows)
DataObj = new DAL();
ds = DataObj.GetDataSet("GetLinksName");
rpt_Config.DataSource = ds.Tables;
rpt_Employee.DataSource = ds.Tables;
rpt_Attendance.DataSource = ds.Tables;
rpt_Report.DataSource = ds.Tables;
**the tables contains set of links that my website contains** ... i want to show some of these links while restrict access to other links dependng on the user role Id for this i use stored proc: GetAllowedLinksForUserRole which return only allowed links correctly ( as i saw it using BreakPoints) ... i m using same databound event for all repeatershere is the item data bound event
protected void rpt_Config_ItemDataBound(object sender, RepeaterItemEventArgs e)
if (e.Item.ItemType == ListItemType.Item)
HtmlAnchor li = (e.Item.FindControl("lnk")) as HtmlAnchor;
if (!CheckLink(int.Parse(DataBinder.Eval(e.Item.DataItem, "LnkId").ToString())))
li.HRef = "";
**the method "CHECKLINK" code":**
private bool CheckLink(int linkID)
**but with the above code it is giving access to those links also which are not in list "AllowedLinks"** can some one please help me with this problem???
**Please note: all the stored procedures and other stuff is working correctly ... its just thecod with in ~~*"rpt_Config_ItemDataBound"*~~ thats causing problem*
Aug 17, 2012 11:31 PM|LINK
Aug 17, 2012 11:39 PM|LINK
How is AllowedLinks accessible in the method CheckLink since it is declared in Page_Load?
Is there another declaration/initialialization of AllowedLinks?
Aug 18, 2012 01:38 AM|LINK
it is being accessed because it is a class attribute ... and plus i have seen values using breakpoints .. the list AllowedLinks do contain what it should throughout. ..
sowhat will u say now? :)
Aug 18, 2012 01:46 AM|LINK
can u please tell how and where wil i use it??
Aug 20, 2012 07:36 AM|LINK
Have you tried using the debugger and inspecting all variables to see what happens?
Aug 20, 2012 07:47 AM|LINK
1) Add this to item type checking:
== ListItemType.Item ||
2) Use HyperLink instead of anchor, then access it by HyperLink.
3) set the Enabled property of HyperLink to control clickable or not.
Aug 20, 2012 10:34 AM|LINK
Yes i did .. all variables or objects , lists do contains what they should ...
Aug 20, 2012 10:39 AM|LINK
@Qin Dian Tang:
Thanksss a million problem solved ... i m getting what i want ... :) ..