![]() |
| ||
| reg OnlineExam Project hi i am joshi. i got a problem in my project, ie i have declared 50 labels with a name q1,q2....q50 now i want to call these labels with a use of for loop..... but how please help me.... |
| ||
| Re: reg OnlineExam Project hii, iam giving an example to display dynamically two labels.hope it is usefull. if u have already have 5 labels in u r page but u want to display only 2 labels ,then this function is usefull label1,label2 be u r label ids in the page dim lbl as string dim l as label for 1=0 to 1 lbl="label"& convert.tostring(i) l=page.findcontrol(lbl) l.visible=true next |
| ||
| Re: reg OnlineExam Project hi thq for your reply... if i wrote l=page.findcontrol(lbl), i am getting an error that Error Cannot implicitly convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.Label'. An explicit conversion exists (are you missing a cast?) how can i slove this problem please reply me..... |
| ||
| Re: reg OnlineExam Project hii, did u declare l as label dim l as label thats the only reason i see for getting the error.the code i gave u was being used by me in my project . |
| ||
| Re: reg OnlineExam Project hii, i have figured it out.since u have declared starting from q1 ,the code i gave works from qo,so here is the correct code Dim i As Integer Dim lbl As Label Dim b As String For i = 0 To 1 b = "label" & Convert.ToString(i + 1) lbl = Page.FindControl(b) lbl.Visible = True Next |
| ||
| Re: reg OnlineExam Project hi thanks for your reply ones again.. i have wrote same code but i am getting an error that "object reference is not set to an instance" |
| ||
| Re: reg OnlineExam Project You should not have to find the labels unless they are nested in another control like a datalist, grid, or repeater, etc. Try telling us what you want to do in this loop. Oh, and the reason why his code isn't working for you is due to a few flaws. The below code is suited for you: Public Function LoopingTheLbls() |
| ||
| Re: reg OnlineExam Project tq i got it. i know what the mistake i am doing. thq ones again |
| All times are GMT -4. The time now is 1:21 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC