Link to home
Start Free TrialLog in
Avatar of 1jaws
1jawsFlag for United States of America

asked on

clickable column

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

ASKER CERTIFIED SOLUTION
Avatar of Stephan
Stephan
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 1jaws

ASKER

thanks
Avatar of 1jaws

ASKER

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...
You can just put the name instead.
Avatar of 1jaws

ASKER

yes, I got it thanks..