Click here to Skip to main content
15,893,401 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Dear all,

how to show grid color selected by admin,staff .
Posted
Comments
AshishChaudha 15-Oct-12 7:46am    
not clear..What you expect from us??
[no name] 15-Oct-12 7:55am    
do you want color acoording to user type ?
Anandkumar D 15-Oct-12 7:58am    
How you know the Admin/Staff?
OriginalGriff 15-Oct-12 8:01am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.

Just add javascript function on mousehover event on itemdatabound event of grid on the basis of role.
 
Share this answer
 
Use the following on .aspx page:-
XML
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
          AutoGenerateColumns="False" DataKeyNames="isdeleted"
          DataSourceID="SqlDataSource1" onrowdatabound="GridView1_RowDataBound">
      <Columns>
          <asp:CheckBoxField DataField="isdeleted" HeaderText="isdeleted"
              SortExpression="isdeleted" />
          <asp:BoundField DataField="tasktype_name" HeaderText="tasktype_name"
              SortExpression="tasktype_name" />
          <asp:BoundField DataField="tasktype_id" HeaderText="tasktype_id"
              InsertVisible="False" ReadOnly="True" SortExpression="tasktype_id" />
      </Columns>
  </asp:GridView>
      <asp:SqlDataSource ID="SqlDataSource1" runat="server"
          ConnectionString="<%$ ConnectionStrings:YourConnectionString %>"
          SelectCommand="SELECT [isdeleted], [tasktype_name], [tasktype_id] FROM [TaskType]">
      </asp:SqlDataSource>


and below is code in RowDataBound to check that checkbox is already checked then show in different color -
C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
       {
           if (e.Row.RowType == DataControlRowType.DataRow)
           {
               //Make datakeys with whom you want to search
               //for me its checkbox.
               bool checkFlag =Convert.ToBoolean (GridView1.DataKeys[e.Row.RowIndex].Value);
               if (checkFlag==true)
               {
                   e.Row.BackColor = System.Drawing.Color.Black;
               }
           }

       }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900