您的位置:首页 > 其它

FormView和ListView的行数据读取分别在什么事件中.

2008-06-05 18:25 399 查看
cs代码:

1).FormView:

protected void plantForm_DataBound(object sender, EventArgs e)

{

FormView me = (FormView)sender;

//如果你要获取formview的数据.

// Part pt=(Part)me.DataItem;//Part是这个表的类.

if (me.DataItem != null)

{

if (!CanEditByMe)

{

ListView contactList = (ListView)me.FindControl("contactList");

contactList.InsertItemPosition = InsertItemPosition.None;

}

}

}

2). ListView:

protected void quotationList_ItemDataBound(object sender, ListViewItemEventArgs e)

{

ListViewDataItem item = (ListViewDataItem)e.Item;

Quotation quotation = (Quotation)item.DataItem; //获取当前行的数据.

//如果item.DataItem里的值和Quotation类里的值不是一一对应的.

// DataBinder.GetPropertyValue(item.DataItem,"Type").ToString() 这样就可以获取某个值了. //获取当前key.(int)me.DataKeys[e.ItemIndex].Value;

ITextControl litUpdateOn = (ITextControl)item.FindControl("litUpdateOn");

if (quotation.IsSubmitted)

{

if (quotation.UpdatedOn != null)

litUpdateOn.Text = Convert.ToDateTime(quotation.UpdatedOn).ToString("yyyy-MM-dd");

else

litUpdateOn.Text = "UpdateOn is null";

}

else

{

ViewState["IsSubmitted"] = "IsSubmitted";

litUpdateOn.Text = "Not Submitted";

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐