JOYSON says:
Hi,
I need to display data in detailview on the basis of users logged in
can anyone hlep me
Here is what I am trying
in my aspx page
<asp:LoginName ID="LoginName1" runat="server" Font-Bold="true" />
<asp:LoginStatus ID="LoginStatus1" runat="server" />
<asp:DetailsView ID="DetailsView1" runat="server" Height="150px" Width="500px" AutoGenerateRows="False"
CellPadding="4" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<CommandRowStyle BackColor="#FFFFC0" Font-Bold="True" />
<FieldHeaderStyle BackColor="#FFFF99" Font-Bold="True" />
<Fields>
<asp:BoundField DataField="pan" HeaderText="PAN Number" HeaderStyle-Height="25px" />
<asp:BoundField DataField="bankname" HeaderText="Bank Name" />
<asp:BoundField DataField="branch_code" HeaderText="Branch Code" />
<asp:BoundField DataField="bank_address" HeaderText="Bank Address" />
<asp:BoundField DataField="account_type" HeaderText="Account Type" />
<asp:BoundField DataField="account_no" HeaderText="Account Number" />
<asp:BoundField DataField="ifsc_code" HeaderText="IFSC Code" />
</Fields>
<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" />
</asp:DetailsView>
and in my code page
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.User.Identity.IsAuthenticated)
{
FormsAuthentication.RedirectToLoginPage();
}
if (!this.IsPostBack)
{
this.BindDetailsView();
}
}
private void BindDetailsView()
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT pan, bankname, branch_code, bank_address, account_type, account_no, ifsc_code FROM tblmadmin"))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
DetailsView1.DataSource = dt;
DetailsView1.DataBind();
}
}
}
}
}
I need to display logged users data inside the detailed view and I am stuck at there pls help me