Asp.net| Solution | array | problem
In doing ASP.net forum to encounter more headaches is the setting of the owner of the problem. To achieve a section of more than a bamboo and a user to serve as a multi-plate, is a two-way consideration. Of course, the split () function method in ASP can be implemented in ASP.net, But for beginners like me, it's always a bit of a hassle. So I want to use a database from the point of view of the table, with DataReader to achieve data reading and verification, the word is turning. Start ...
First, we set up a data table for storing the settop.
ID (number) primary key username (text) is the owner name news_id (number) for forum section ID
ID username news_id
1 overred 10
2 Red 11
3 overred 11
4 Red 10
Let's start with a few pages.
______________________
Index.aspx
The display of each section shows the following
NEW_ID Column name 10 casually chat >>11asp program design >>12asp. NET programming >> 13 other computer problems >>
The news_id in this page is uploaded to Bbs.aspx and the following code is set in Bbs.aspx.cs:
public void Isbanzhu ()//judge whether it is a moderator
{
Try
{
String datas= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" +server.mappath ("Overred.mdb");
OleDbConnection conn = new OleDbConnection (datas);
Conn. Open ();
String st=request.querystring["news_id"];
String Sql= "select * from Settop where username= @st";
OleDbCommand cmd=new OleDbCommand (sql,conn);
Cmd. Parameters.Add ("@st", oledbtype.varchar,100). value=st;
OleDbDataReader Dr;
Dr=cmd. ExecuteReader ();
while (Dr. Read ())//loop reading and comparing with St
{
if (dr["news_id"]. ToString () ==st)
This.bzmanage.visible=true;
This.isbz.visible=true;
}
}
catch (OleDbException ex)
{
Response.Write (ex);
}
}
Through the while (Dr. Read ())/circular read and compared with St, the implementation of the this.bzmanage.visible=true in accordance with the conditions; This.isbz.visible=true; In the label bzmanage and hyperlink isbz You can set the function of the moderator.
asp.net forum in a panel of more than the owner and a user as a multi-plate issue on the solution to pull. Other settings you can do it yourself!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.