FormView的数据绑定 [英] FormView Data Binding

查看:145
本文介绍了FormView的数据绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的数据源领域,我想在一个标签字段合并和显示。我添加了一个程序来捕捉数据绑定行动,但我不知道如何获取数据的数据源。我上显示一个FormView这些信息,使ANLY差异。我可以在C#得到一个例子吗?

例如 -

 保护无效DisplayPayOut(对象发件人,EventArgs的发送)
{
    标签奖金= FormView1.FindControl(PayoutLabel)作为标签;
    Payout.Text = datasource.field1 + datasource.field2;
}


解决方案

我不能完全肯定,但好像你正在寻找类似如下:

 保护无效DisplayPayOut(对象发件人,EventArgs的发送)
{
    标签奖金= FormView1.FindControl(PayoutLabel)作为标签;
    反对的DataItem = DataBinder.GetDataItem(FormView1);
    。Payout.Text =的DataBinder.Eval(DataItem的field1NameHere)的ToString()+ DataBinder.Eval的(DataItem的field2Namehere)的ToString()。
}

I have for fields in my datasource that I want to combine and display in one label field. I have added a procedure to capture the databinding action but I don't how to get the data out of the datasource. I am displaying this information on a FormView is that makes anly difference. Can I get an example in c#?

For example -

protected void DisplayPayOut(object sender, EventArgs e)
{
    Label Payout = FormView1.FindControl("PayoutLabel") as Label;
    Payout.Text = datasource.field1 + datasource.field2;
}

解决方案

I'm not fully sure but it seems like you're looking for something like the following:

protected void DisplayPayOut(object sender, EventArgs e)
{
    Label Payout = FormView1.FindControl("PayoutLabel") as Label;
    object dataItem = DataBinder.GetDataItem(FormView1);
    Payout.Text = DataBinder.Eval(dataItem, "field1NameHere").ToString() + DataBinder.Eval(dataItem, "field2Namehere").ToString();
}

这篇关于FormView的数据绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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