could everyone show me the way to change CType in VB.NET to C#?
-
Hi,i can not change this statement in VB.NET to C#.Could everyone helpme?
Dim strCompanyName as String strCompanyName = CType(dgItem.FindControl("lblCompanyName"), Label).Text
with "dgItem" is DataGridItem and "lblCompanyName" is the id of a label (server control).I've tried thisLabel lb=(Label)dgItem.FindControl("lblCompanyName"); Response.Write(lb.Text);
but it did not work.Thanks for all replies. -
Hi,i can not change this statement in VB.NET to C#.Could everyone helpme?
Dim strCompanyName as String strCompanyName = CType(dgItem.FindControl("lblCompanyName"), Label).Text
with "dgItem" is DataGridItem and "lblCompanyName" is the id of a label (server control).I've tried thisLabel lb=(Label)dgItem.FindControl("lblCompanyName"); Response.Write(lb.Text);
but it did not work.Thanks for all replies.The code you posted looks correct, do you get any specific error? What do you mean by "but it did not work." Current blacklist svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
-
Hi,i can not change this statement in VB.NET to C#.Could everyone helpme?
Dim strCompanyName as String strCompanyName = CType(dgItem.FindControl("lblCompanyName"), Label).Text
with "dgItem" is DataGridItem and "lblCompanyName" is the id of a label (server control).I've tried thisLabel lb=(Label)dgItem.FindControl("lblCompanyName"); Response.Write(lb.Text);
but it did not work.Thanks for all replies. -
Hi,i can not change this statement in VB.NET to C#.Could everyone helpme?
Dim strCompanyName as String strCompanyName = CType(dgItem.FindControl("lblCompanyName"), Label).Text
with "dgItem" is DataGridItem and "lblCompanyName" is the id of a label (server control).I've tried thisLabel lb=(Label)dgItem.FindControl("lblCompanyName"); Response.Write(lb.Text);
but it did not work.Thanks for all replies. -
The code you posted looks correct, do you get any specific error? What do you mean by "but it did not work." Current blacklist svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
-
Try: Label lb = (System.Web.UI.WebControls.Label)dgItem.FindControl("lblCompanyName"); Response.Write(lb.Text); HTH
-
Looks to me that it prints the code of the label but it's empty at this time... OR that this code is never actually executed. Try printing out a few non-space characters before and after the label text like: Response.Write("*** "+lb.Text+" ***"); Now if you see some asterisks in the result then you know it's printing empty label. Then you have to figure out when this code is executed and what you actually have on this label. If you can't see any asterisks then obviously this code never gets executed... HTH
-
Hi,i can not change this statement in VB.NET to C#.Could everyone helpme?
Dim strCompanyName as String strCompanyName = CType(dgItem.FindControl("lblCompanyName"), Label).Text
with "dgItem" is DataGridItem and "lblCompanyName" is the id of a label (server control).I've tried thisLabel lb=(Label)dgItem.FindControl("lblCompanyName"); Response.Write(lb.Text);
but it did not work.Thanks for all replies.From our Instant C# VB to C# converter: string strCompanyName = null; strCompanyName = ((Label)(dgItem.FindControl("lblCompanyName"))).Text; Note that your original conversion was attempting to cast "dgItem" to a Label. David Anton www.tangiblesoftwaresolutions.com Instant C#: VB to C# converter Instant VB: C# to VB converter Instant C++: C# to C++ converter Instant C++: VB to C++ converter Clear VB: Cleans up VB.NET code
-
Hi,i can not change this statement in VB.NET to C#.Could everyone helpme?
Dim strCompanyName as String strCompanyName = CType(dgItem.FindControl("lblCompanyName"), Label).Text
with "dgItem" is DataGridItem and "lblCompanyName" is the id of a label (server control).I've tried thisLabel lb=(Label)dgItem.FindControl("lblCompanyName"); Response.Write(lb.Text);
but it did not work.Thanks for all replies.Are you using masterpages ?? If you are then the controls id will not be "lblCompanyName"...it will be something like "ctl00_Main_lblCompanyName"...which is prefixed by the content placeholders id....so you should use the following code.
Label lb=(Label)dgItem.FindControl(this.lblCompanyName.ClientID); Response.Write(lb.Text);
This may help..possibly Cheers, Craig ** I'd rather try and fail than fail to try ;) **