开发者

Row Transfer according to the person login

I have two pages, called "Staff_Common" & "开发者_Go百科Staff_Main". Both pages have a gridview.

"Staff_Common" can be view by all staff. but "Staff_Main" is personal for each staff.

My question is, when a particular person login, how to transfer a row from "Staff_Common" gridview to "Staff_Main" gridview if the user click on a row at "Staff_Common" according to the user which clicked it?


To get the data in the "Staff_Main" page according to the row clicked in "Staff_Common" page you need to somehow *pass the ID of the Staff corresponding to a row clicked in the Staff_Common page* to the Staff_Main page so it can generate the GridView accordingly.

To do that you need to set the properties:

AutoGenerateSelectButton="true"
DataKeyNames="id"
OnSelectedIndexChanged="StaffCommon_OnSelectedIndexChanged"

on the Staff_Common GridView. DataKeyNames value must be the name of the column that stores the id.

Then in the code behind of same page store in session the ID of the item on which was clicked:

protected void StaffCommon_OnSelectedIndexChanged(object sender, EventArgs e)
{
    Session["staffId"] = (sender as GridView).SelectedDataKey;
}

Now all you have to do is to bind the data in Staff_Main page accordingly to the id stored in session: Session["staffId"].

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜