BASED ON LOGGED USERNAME TO FILTER DATA IN GRIDVIEW

Munikumar G

Total Post:9

Points:63
Posted by  Munikumar G
 6232  View(s)
Ratings:
Rate this:
Post is removed by the User.
  1. Awadhendra Tiwari

    Post:126

    Points:882
    Re: Based on logged username to filter data in Gridview

    Hi,         

      In gridview display data as login username.

    Thanks

     

    MuniKumar,

    What you trying to ask?
     You can paste you code here.

    Here I am providing some links related with datagridview in asp.net which might be useful for you.

    1.      GridView Decoration in ASP.NET

    2.       GridView inside GridView in ASP.NET(Nested GridView)

    3.       GridView Control in ASP.Net

    Thanks

      Modified On Oct-28-2016 04:17:23 AM
  1. Munikumar G

    Post:9

    Points:63
    Re: Based on logged username to filter data in Gridview

    Post is removed by the User.

  1. Munikumar G

    Post:9

    Points:63
    Re: Based on logged username to filter data in Gridview

    Hi,

    This is my code

    who has to login in the site display user details only on gridview.  

    please send me the code asap.

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True"

    AutoGenerateColumns="False" DataKeyNames="ApptId" DataSourceID="SqlDataSource1"

    CellPadding="4" ForeColor="#333333" GridLines="None" AllowSorting="True">

    <AlternatingRowStyle BackColor="White" />

    <Columns>

    <asp:BoundField DataField="ClientId" HeaderText="ClientName"

    SortExpression="ClientId" />

    <asp:BoundField DataField="UserId" HeaderText="UserName"

    SortExpression="UserId" />

    <asp:BoundField DataField="ApptTime" HeaderText="ApptTime"

    SortExpression="ApptTime" />

    <asp:BoundField DataField="ApptDate" HeaderText="ApptDate"

    SortExpression="ApptDate" />

    <asp:BoundField DataField="Duration" HeaderText="Duration"

    SortExpression="Duration" />

    <asp:BoundField DataField="MOM" HeaderText="MOM" SortExpression="MOM" />

    <asp:BoundField DataField="SalesExecutiveObjects"

    HeaderText="SalesExecutiveObjects" SortExpression="SalesExecutiveObjects" />

    <asp:BoundField DataField="SalesProjection" HeaderText="SalesProjection"

    SortExpression="SalesProjection" />

    <asp:BoundField DataField="NextFollowUpDate" HeaderText="NextFollowUpDate"

    SortExpression="NextFollowUpDate" />

    <asp:BoundField DataField="ExecutedClosingDate"

    HeaderText="ExecutedClosingDate" SortExpression="ExecutedClosingDate" />

    <asp:BoundField DataField="Remarks" HeaderText="Remarks"

    SortExpression="Remarks" />

    <asp:BoundField DataField="StatusId" HeaderText="StatusName"

    SortExpression="StatusId" />

    </Columns>

    <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />

    <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />

    <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />

    <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />

    <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />

    <SortedAscendingCellStyle BackColor="#FDF5AC" />

    <SortedAscendingHeaderStyle BackColor="#4D0000" />

    <SortedDescendingCellStyle BackColor="#FCF6C0" />

    <SortedDescendingHeaderStyle BackColor="#820000" />

    </asp:GridView>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MarketingSheetConnectionString %>"

    SelectCommand="SELECT*FROM [Appointment]" ></asp:SqlDataSource>

    Thanks

  1. Chris Anderson

    Post:65

    Points:455
    Re: Based on logged username to filter data in Gridview

    hi,

    If you want to display data of logged in user, you have to create the following sql query:

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:workbookConnectionString %>"
                SelectCommand="SELECT * FROM [clientDetails] WHERE ([id] = @id)">
                <SelectParameters>
                    <asp:SessionParameter DefaultValue="" Name="id" SessionField="clientID"
                        Type="Int32" />
                </SelectParameters>
    </asp:SqlDataSource>

    In the above query a session field is created (id) in which you have to pass the id of user in order to display data in gridview.

    Thanks.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!