Link to home
Start Free TrialLog in
Avatar of ETKN
ETKN

asked on

Using the ItemDataBound on a Datagrid

ItemDataBound  make rows in datagrid clickable (onclick) if users have access to organization

Example: I have a datagrid that looks similar to the one below:

ROW Organization     Employee Count     Total Salary
 1            23                         5                    $150,000
 2            321                       7                    $280,000
 3            258                       27                 $1,256,325
 
I want to make the rows clickable (onclick) if the users have access to that organization.  When they click the row it will take them to a more detail page.

I have a stored procedure that looks like this

  ALTER   PROCEDURE dbo.GetOranizationByEmpId
  @EmployeeId int
AS
  SET NOCOUNT ON
  SELECT OrganizationID FROM OrganizationAccess
  WHERE EmployeeId = @EmployeeId AND Active = 1

When the EmployeeID is passed in it will return a list of values

EXAMPLE:
23
258

 With the example above row 1 and 3 should have an onclick event associated with it.

Im assuming this will all be done in the ItemDataBound associated with the DataGrid.  Im just not sure how to get started.  Any Ideas???
Avatar of 3abqari
3abqari

Are you using .NET 1.1?
Avatar of ETKN

ASKER

yes 1.1
ASKER CERTIFIED SOLUTION
Avatar of 3abqari
3abqari

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
And inside the columns tag that's inside the <asp:Datagrid> tag, put the following:

<asp:TemplateColumn>
      <ItemTemplate>
            <asp:HyperLink runat="server" ID="lnkViewDetails">View</asp:HyperLink>
      </ItemTemplate>
</asp:TemplateColumn>

Or a

<asp:TemplateColumn>
      <ItemTemplate>
            <asp:Button runat="server" ID="btnViewDetails">View</asp:Button>
      </ItemTemplate>
</asp:TemplateColumn>

Depending on what you want to do after they select one of the rows