Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > DataGrid - if/else in edititemtemplate?

Reply
Thread Tools

DataGrid - if/else in edititemtemplate?

 
 
JW
Guest
Posts: n/a
 
      05-16-2004
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


 
Reply With Quote
 
 
 
 
JW
Guest
Posts: n/a
 
      05-16-2004
Ok, I ditched my first idea, and was able to get the concept working by just
adding both controls ( a linkbutton - I initially thought a hyperlink would
work, but I decided on linkbutton instead - and a textbox ) and just setting
the visibility to true/false depending on whether or not a password was
present in my "onitemdatabound" method. Here is a sample of what I did:

<asp:templatecolumn headertext="Password">
<edititemtemplate>
<asp:textbox id="password_Textbox" runat="server" text=""
width="100" maxlength="50"></asp:textbox>
<asp:linkbutton id="password_Reset" runat="server" text="reset"
commandname="ResetPassword"></asp:linkbutton>
</edititemtemplate>
</asp:templatecolumn>

Justin



"JW" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Datagrid: how cut short display of a long description in a datagrid column Brian K. Williams ASP .Net 0 03-02-2004 08:35 PM
RE: Datagrid: how cut short display of a long description in a datagrid column =?Utf-8?B?U3VyZXNo?= ASP .Net 0 03-02-2004 08:31 PM
datagrid in datagrid BK Kim ASP .Net 1 03-02-2004 06:34 AM
Call Datagrid Command column outside datagrid Dave ASP .Net 0 11-20-2003 11:11 AM
To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible? Andreas Klemt ASP .Net Datagrid Control 0 10-08-2003 01:19 AM



Advertisments