Valerie Meunier

Valerie Meunier

  • NA
  • 693
  • 83.1k

3 errors when converting from vb.net

Apr 13 2021 1:31 PM
Hi
 
I have converted an application from vb.net to C# but with three errors.
 
Thanks for helping me.
Valerie
 
1) if (e.Row.RowState == 0 | e.Row.RowState == 1)
 
=> Operator '==' cannot by applied to operands of type 'System.Web.UI.WebControls.DataControlRowState' and 'int'
 
The error occurs right of the | sign (e.Row.RowState == 0 doesn't give an error).
 
2) How to convert this code from vb.net to C#: check whether the inputs are actually valid dates
 
if Not IsDate(e.Values("begdat")) Or Not IsDate(e.Values("enddat") then
 
I tried this: if ( ! e.Values["begdat"] is DateTime | ! e.Values["enddat"] is DateTime )
 
but then error: Operator '!' cannot by applied to operands of type 'System.DateeTime
 
3) var naamtxt = new TextBox();
foreach (var dvr in DetailsView1.Rows)
naamtxt = (TextBox)dvr.FindControl("naamtxt");
naamtxt.Focus();
 
Code in the aspx page:
 
<asp:TemplateField ><InsertItemTemplate>
<asp:TextBox id="naamtxt" runat="server" Text='<%# Bind("naam") %>' ></asp:TextBox>
</InsertItemTemplate></asp:TemplateField>
 
This gives the error: "object does not contain a definition for 'FindControl' ..."

Answers (3)