Click here to Skip to main content
15,888,461 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionHtmlTextWriter vs HtmlTable.RenderControl Pin
dashing_inn200323-Sep-15 17:57
professionaldashing_inn200323-Sep-15 17:57 
AnswerRe: HtmlTextWriter vs HtmlTable.RenderControl Pin
Richard MacCutchan23-Sep-15 21:45
mveRichard MacCutchan23-Sep-15 21:45 
QuestionHow to display results based on employees manager and department Pin
samflex22-Sep-15 17:23
samflex22-Sep-15 17:23 
AnswerRe: How to display results based on employees manager and department Pin
Herman<T>.Instance23-Sep-15 0:24
Herman<T>.Instance23-Sep-15 0:24 
SuggestionRe: How to display results based on employees manager and department Pin
Richard Deeming23-Sep-15 1:55
mveRichard Deeming23-Sep-15 1:55 
GeneralRe: How to display results based on employees manager and department Pin
samflex23-Sep-15 2:37
samflex23-Sep-15 2:37 
AnswerRe: How to display results based on employees manager and department Pin
F-ES Sitecore23-Sep-15 5:56
professionalF-ES Sitecore23-Sep-15 5:56 
GeneralRe: How to display results based on employees manager and department Pin
samflex23-Sep-15 17:36
samflex23-Sep-15 17:36 
I am really sorry guys.

I was showing wrong code.

The correction made by Richard is great and will be used on employeeDetails.aspx page.

However, where my issue lies on the current page.

We would like to show all records related to a department to be displayed when the manager of that department logs on to that page.

As a result, I am trying to use the managerId and department to filter the records.

I am trying to hide the managerId and department Id on the markup but use them to filter the records.

Currently, I am using just the department. If it works, I will add the manager but the department is not working.

Here is the department that I added to the gridview:

XML
<asp:BoundField DataField="department">
 <ItemStyle CssClass="dhide"/>


XML
<asp:BoundField DataField="department">
 <ItemStyle CssClass="dhide"/>


and I want to pass the value to the SELECT statement on codebehind.

Any ideas how to do this?

I will show the code again for clarity with some slight modifications:



XML
<head>
    <style type="text/css">
    .dhide
    {
        display:none;
    }
</style>
</head>
<div align="center">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" AllowPaging="true"
        OnPageIndexChanging="OnPageIndexChanging" PageSize="10">
        <Columns>
             <asp:BoundField DataField="department">
              <ItemStyle CssClass="dhide"/>
              <asp:HyperLinkField DataNavigateUrlFields="ManagerID,department"
                DataNavigateUrlFormatString="employeeDetails.aspx?ID={0}&Dept={1}" Text="Add Comments" />
            <asp:BoundField ItemStyle-Width="200px" DataField="empname" HeaderText="Employee Name" />
            <asp:BoundField ItemStyle-Width="250px" DataField="department" HeaderText="Department" />
         </Columns>
    </asp:GridView>
</div>

'//Code behind:
<pre>    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        If Not Me.IsPostBack Then
            Me.BindGrid()
        End If
    End Sub
 
    Private Sub BindGrid()
        Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
        Using con As New SqlConnection(constr)
            Using cmd As New SqlCommand("SELECT e.empID, e.empname, e.department, a.managerID, a.status FROM Emp e INNER JOIN Angulers a ON a.empID = e.empID WHERE a.status = 'Done' and e.ManagerID = '"&querystring("ID") & "' and e.department = '"&uerystring("dept") & "' ")
                'We use parametized query to prevent sql injection attack
                '  Dim p1 As New SqlParameter("@dept", Session("dept"))
                'cmd.Parameters.Add(p1)
                Using sda As New SqlDataAdapter()
                    cmd.Connection = con
                    sda.SelectCommand = cmd
                    Using dt As New DataTable()
                        sda.Fill(dt)
                        GridView1.DataSource = dt
                        GridView1.DataBind()
                    End Using
                End Using
            End Using
        End Using
    End Sub


GeneralRe: How to display results based on employees manager and department Pin
F-ES Sitecore23-Sep-15 21:57
professionalF-ES Sitecore23-Sep-15 21:57 
GeneralRe: How to display results based on employees manager and department Pin
samflex24-Sep-15 3:42
samflex24-Sep-15 3:42 
GeneralRe: How to display results based on employees manager and department Pin
F-ES Sitecore24-Sep-15 3:48
professionalF-ES Sitecore24-Sep-15 3:48 
QuestionHow to open javasript pop on button click Pin
Member 1200294722-Sep-15 1:34
Member 1200294722-Sep-15 1:34 
AnswerRe: How to open javasript pop on button click Pin
JHizzle22-Sep-15 2:47
JHizzle22-Sep-15 2:47 
AnswerRe: How to open javasript pop on button click Pin
F-ES Sitecore22-Sep-15 7:17
professionalF-ES Sitecore22-Sep-15 7:17 
QuestionAspdotnet webservice using in HTML with Javascript Pin
J.Ramanjaneyulu21-Sep-15 4:17
J.Ramanjaneyulu21-Sep-15 4:17 
AnswerRe: Aspdotnet webservice using in HTML with Javascript Pin
Richard MacCutchan21-Sep-15 5:20
mveRichard MacCutchan21-Sep-15 5:20 
AnswerRe: Aspdotnet webservice using in HTML with Javascript Pin
Blikkies21-Sep-15 19:52
professionalBlikkies21-Sep-15 19:52 
GeneralRe: Aspdotnet webservice using in HTML with Javascript Pin
J.Ramanjaneyulu28-Sep-15 15:42
J.Ramanjaneyulu28-Sep-15 15:42 
QuestionRe: Aspdotnet webservice using in HTML with Javascript Pin
Blikkies28-Sep-15 19:37
professionalBlikkies28-Sep-15 19:37 
QuestionHelp .aspx/ going to another page Pin
Member 1199854620-Sep-15 14:44
Member 1199854620-Sep-15 14:44 
AnswerRe: Help .aspx/ going to another page Pin
Richard Andrew x6420-Sep-15 15:14
professionalRichard Andrew x6420-Sep-15 15:14 
GeneralRe: Help .aspx/ going to another page Pin
Member 1199854620-Sep-15 16:28
Member 1199854620-Sep-15 16:28 
GeneralRe: Help .aspx/ going to another page Pin
Richard Andrew x6420-Sep-15 16:33
professionalRichard Andrew x6420-Sep-15 16:33 
AnswerRe: Help .aspx/ going to another page Pin
Richard Deeming21-Sep-15 2:39
mveRichard Deeming21-Sep-15 2:39 
QuestionMVC Java Script Help Required Pin
Member 766920320-Sep-15 13:03
Member 766920320-Sep-15 13:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.