Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i try to show documents specifically like hr admin only view hr documents and finance admin only view finance documents for this first i create a sp

SQL
alter procedure sphrdoc

@UserName  nvarchar(50),
@Password nvarchar(50)
as
select DepID from Userss where UserName=@UserName AND [Password]=@Password


and
C#
Session["a"] = dd.hrdoc(Convert.ToString(Session["Login2"]), (Convert.ToString(Session["Login3"])))
;

when admin user signup then his/her department id also save in userss table..

then i create a sp
SQL
create procedure sphrdocid1
@DepID int
as
select * from DocumentInfo where DepID=@DepID



and then i also a create a funtion

SQL
public int  hrdoc(string Username,string password)
      {
          return Convert.ToInt32( db.ExecuteScalar("sphrdoc",new object[]{Username,password}));

      }
      public DataTable hrdoc1(int id)
      {
          return db.ExecuteDataSet("sphrdocid1",new object[]{id}).Tables[0];


      }



and

C#
GrdFileApprove.DataSource = dd.hrdoc1(Convert.ToInt32(Session["a"]));
                GrdFileApprove.DataBind();


and gridview code is

XML
<asp:GridView ID="GrdFileApprove" runat="server" BackColor="White"
                  BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4"
                  GridLines="Horizontal" AutoGenerateColumns="False"
                    onrowcommand="GrdFileApprove_RowCommand"
                OnRowDataBound="OnRowDataBound"
                onselectedindexchanged="GrdFileApprove_SelectedIndexChanged1" >
                     <Columns>
                       <asp:TemplateField HeaderText="S no">
                           <ItemTemplate>
                               <%# Container.DataItemIndex+1 %>
                               <asp:HiddenField runat="server" ID="HdnFileID" Value='<%# Eval("DocID") %>' />
                           </ItemTemplate>
                       </asp:TemplateField>
                       <asp:BoundField DataField="DocID" HeaderText="DocumentID"  />
                       <asp:BoundField DataField="DocName" HeaderText="DocName"  />
                       <asp:BoundField DataField="Uploadfile" HeaderText="File Name" />
                       <asp:BoundField DataField="DocType" HeaderText="Document" />
                       <asp:BoundField DataField="DepType" HeaderText="Department" />

<%--                      <asp:BoundField HeaderText="ApproveID" DataField="ApproveID" ></asp:BoundField>
--%>              <asp:TemplateField>
                    <ItemTemplate>
                       <asp:Label ID="lblCountry" runat="server" Text='<%# Eval("ApproveID") %>' Visible = "false" />

                        <asp:DropDownList ID="DropDownList4" runat="server" EnableViewState="true" class="vpb_dropdown" DataTextField="ApproveType" DataValueField="ApproveID" AutoPostBack="true" OnSelectedIndexChanged="DropDownList4_SelectedIndexChanged">
                             <asp:ListItem Text="Pending" selected="selected" Value="3"></asp:ListItem>
                             <asp:ListItem Text="Approve" Value="1"></asp:ListItem>
                             <asp:ListItem Text="Reject" Value="2"></asp:ListItem>
                        </asp:DropDownList>
                    </ItemTemplate>
                </asp:TemplateField>




but it shows me error in this line
C#
GrdFileApprove.DataBind();




any solution?
Posted
Updated 22-Oct-13 8:00am
v2
Comments
Ranjan.D 22-Oct-13 14:36pm    
Put a breakpoint on line GrdFileApprove.DataBind(); and check whether the datasource has a column for DocType.
Diya Ayesa 22-Oct-13 14:43pm    
but in database there is record of doctype
Ranjan.D 22-Oct-13 14:45pm    
It doesn't matter. Did you do single step debug and try to verify whether the DataTable has that particular column or not ?
Diya Ayesa 22-Oct-13 15:04pm    
yes i set a breakpoint but it can not even go on that line <asp:BoundField DataField="DocType" HeaderText="Document" />


and it show me error on this line GrdFileApprove.DataBind();
Ranjan.D 22-Oct-13 15:08pm    
Wait you have to set a breakpoint on the below line on GrdFileApprove.DataSource , Then hit F11 for single step debug, then check the GrdFileApprove.DataSource , use visualizer to see the datatable.

GrdFileApprove.DataSource = dd.hrdoc1(Convert.ToInt32(Session["a"]));
GrdFileApprove.DataBind();

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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