检索当前登录用户 [英] Retrieve Current Login User

查看:102
本文介绍了检索当前登录用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助.是的,很认真.我已经像一个月一样实现了这个所谓的系统.到目前为止,一切都还不错,但是当涉及到数据库时,我遇到了麻烦!好的,我有8个文本框,允许用户输入数据.我将每个文本框都声明为列名,因此在用户输入数据后,文本框的所有值将根据其列名分别保留在行中.这部分完成了.现在的问题是,我该如何检索仅与用户有关的所有数据,可以说用户A只想查看需要在gridview中显示的她/他的数据.谢谢你.我的表也有用户名列.

I need help. Yes, like seriously. I have been implement this so called system like a month. So far, everything is just nice but when it comes to database thingy I got STUCK! Ok, i have 8 textboxes which allow user to enter data. I declare each of the textbox as a column name so after user key in their data, all the value of the textbox will be kept in row respectively according to their column name. That part is done. The problem now, how can i retrieve back all the data that only related to user, lets say User A want to view only her/his data that need to be shown in gridview. Thank you. My table got username column too.

private string months;
private string expen1;
private string price1;
private string expen2;
private string price2;
private string expen3;
private string price3;
private string expen4;
private string price4;
private string expen5;
private string price5;
private string expen6;
private string price6;
private string expen7;
private string price7;
private string expen8;
private string price8;

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGridview();
}
}
protected void BindGridview()
{
gvDetails.DataSource = (i dont know what to put here)
gvDetails.DataBind();
}
protected void gvDetails_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvDetails.EditIndex = -1;
BindGridview();
}
protected void gvDetails_RowEditing(object sender, GridViewEditEventArgs e)
{
gvDetails.EditIndex = e.NewEditIndex;
BindGridview();
}
protected void gvDetails_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
//* i dont know this part too (delete section)
}
protected void gvDetails_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
//* this is for update thingy. Stuck too
gvDetails.EditIndex = -1;
BindGridview();
}

推荐答案

您需要从有关ADO.Net的教程中学习:-

http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson01.aspx [ ^ ]

为初学者使用ADO.NET [ http://msdn.microsoft.com/en-us/library/dw70f090.aspx [ ^ ]

http://www.quackit.com/sql_server/sql_server_2008/tutorial/ [ http://archive.msdn.microsoft.com/SQLTutorials [ http://www.tizag.com/sqlTutorial/ [ http://en.kioskea.net/forum/affich-61898-how-to-make-make-database-connectivity-in-asp-net [
You need to learn from the tutorials about ADO.Net:-

http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson01.aspx[^]

Using ADO.NET for beginners[^]

http://msdn.microsoft.com/en-us/library/dw70f090.aspx[^]

http://www.quackit.com/sql_server/sql_server_2008/tutorial/[^]

http://archive.msdn.microsoft.com/SQLTutorials[^]

http://www.tizag.com/sqlTutorial/[^]

http://en.kioskea.net/forum/affich-61898-how-to-make-database-connectivity-in-asp-net[^]

I hope this will help you out.


这篇关于检索当前登录用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆