J
JW
Greetings -
I am working with a DataGrid, and am trying to set up a template column for
a password field which is stored in a database. Basically, when the
"EditCommand" is executed, for the EditItemTemplate, I would like to display
a HyperLink if a password exists for this particular table row, or a TextBox
if one does not. ( the hyperlink will be a "reset" link, whereas the
textbox will allow the user to enter a password if one does not exist. Here
is my code so far, which I'm sure is far from correct ( pwdLength is an
int ):
<asp:templatecolumn headertext="Password">
<edititemtemplate>
<%# if( DataBinder.Eval( Container.DataItem, "pwdLength" ) == 0 )
{
<asp:textbox id="password_Textbox" runat="server"
text="something" visible="True"></asp:textbox>
} else {
<asp:hyperlink id="password_Link" runat="server" text="reset"
navigateurl="tobedecided" />
} %>
</edititemtemplate>
</asp:templatecolumn>
Currently, the browser compiler is complaining "Invalid expression term
'if'"...... am I going about this completely wrong? I do have a
code-behind file where most of my C# code is, however for some reason I
thought this if/else should go in the .aspx file.
Thanks in advance,
Justin
I am working with a DataGrid, and am trying to set up a template column for
a password field which is stored in a database. Basically, when the
"EditCommand" is executed, for the EditItemTemplate, I would like to display
a HyperLink if a password exists for this particular table row, or a TextBox
if one does not. ( the hyperlink will be a "reset" link, whereas the
textbox will allow the user to enter a password if one does not exist. Here
is my code so far, which I'm sure is far from correct ( pwdLength is an
int ):
<asp:templatecolumn headertext="Password">
<edititemtemplate>
<%# if( DataBinder.Eval( Container.DataItem, "pwdLength" ) == 0 )
{
<asp:textbox id="password_Textbox" runat="server"
text="something" visible="True"></asp:textbox>
} else {
<asp:hyperlink id="password_Link" runat="server" text="reset"
navigateurl="tobedecided" />
} %>
</edititemtemplate>
</asp:templatecolumn>
Currently, the browser compiler is complaining "Invalid expression term
'if'"...... am I going about this completely wrong? I do have a
code-behind file where most of my C# code is, however for some reason I
thought this if/else should go in the .aspx file.
Thanks in advance,
Justin