clickable column

1jaws
1jaws used Ask the Experts™
on
This code below makes Name column in my grid all clickable and redirects, but what I need is only when loginPassword is null and ((bool)Session["Account"] == true)
I tried to put that in MakeLInk code below and I added this code but it only makes one row clickable even though I have two null password rows(records)
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item.ItemType == GridItemType.AlternatingItem ||
            e.Item.ItemType == GridItemType.Item)
        {

            Password = DataBinder.Eval(e.Item.DataItem, "loginPassword").ToString();

            GridDataItem dataItem = (GridDataItem)e.Item;

            if (Password == "")

                SetPassword = "";
           
        }  
    }
<radG:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" CellPadding="4"
            DataSourceID="dsManager" ForeColor="#333333" GridLines="None" 
            Width="600px"  OnItemCommand = "RadGrid1_ItemCommand"   OnItemDataBound="RadGrid1_ItemDataBound"
            >
            <MasterTableView  DataKeyNames="ID,displayName,loginPassword"
                DataSourceID="dsManager"  EditMode="InPlace">
                <RowIndicatorColumn Visible="False">
                    <HeaderStyle Width="20px" />
                </RowIndicatorColumn>
                <ExpandCollapseColumn Visible="False">
                    <HeaderStyle Width="19px" />
                </ExpandCollapseColumn>
                <Columns>
                     
                    <radG:GridButtonColumn ButtonType="ImageButton" ImageUrl="~/images/edit.gif" CommandName="Edit"
                        Text="Update" UniqueName="Edit" /> 
                                               
                       <radG:GridBoundColumn DataField="profileID" HeaderText="ID" SortExpression="ID"
                          UniqueName="ID" Visible="false">
                      </radG:GridBoundColumn>
                      
                      
                      <radG:GridTemplateColumn HeaderText="Name" UniqueName="displayName">
                            <ItemTemplate>
                                <%# MakeLink(Convert.ToString(DataBinder.Eval(Container.DataItem, "displayName")))%>
                            </ItemTemplate>
                      </radG:GridTemplateColumn>
                     
                    
                    <radG:GridTemplateColumn HeaderText="Password" SortExpression="loginPassword"
                          UniqueName="loginPassword">
                          <ItemTemplate>
                              <asp:Label runat="server" ID="lblloginPassword" Text='<%# new string(char.Parse("*"),Eval("loginPassword").ToString().Length) %>'></asp:Label>
                          </ItemTemplate>
                        <EditItemTemplate>
                              <asp:TextBox runat="server" ID="txtlogin" TextMode="Password" value='<%# Eval("loginPassword") %>' ></asp:TextBox>
                          </EditItemTemplate>
                      </radG:GridTemplateColumn>
  
code behind
public string MakeLink(string displayName)
    {
        string returnValue;


        if ((bool)Session["Account"] == true)
            returnValue = "<a href='myaccount.aspx?ID=" + Session["ID"] + "' Target='_blank' >" + displayName + "</a>";
        else
            returnValue = "&nbsp;";
        return returnValue;
    }

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Lead Software Engineer
Commented:
Why not adding the Password to your function like this

<%# MakeLink(Convert.ToString(DataBinder.Eval(Container.DataItem, "displayName")), Convert.ToString(DataBinder.Eval(Container.DataItem, "loginPassword")))%>

and

public string MakeLink(string displayName, string loginPassword)
    {
        string returnValue;


        if ((bool)Session["Account"] == true && !String.IsNullOrEmpty(loginPassword))
            returnValue = "<a href='myaccount.aspx?ID=" + Session["ID"] + "' Target='_blank' >" + displayName + "</a>";
        else
            returnValue = "&nbsp;";
        return returnValue;
    }

Author

Commented:
thanks

Author

Commented:
actually, is it possible to not to make the else to return not &nbsp; that time name fields shows empty... I want that to show.. but not clickable that time...
StephanLead Software Engineer

Commented:
You can just put the name instead.

Author

Commented:
yes, I got it thanks..

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial