111,125
社区成员
发帖
与我相关
我的任务
分享在WinForm DataGridView一列如何绑定多个字段?
如在Asp.net中绑定:
<asp:GridView ID="gvwPerDetail" runat="server" AutoGenerateColumns="False" DataKeyNames="ID">
<Columns>
<asp:TemplateField HeaderText="姓名(身份证)">
<HeaderStyle Width="130px" />
<ItemTemplate>
<%# Eval("IDCard")+"("+Eval("IDCard")+")" %>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>这么没用啊?调试时事件也没执行到
private void gvwList_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
DataGridViewRow row = this.gvwList.Rows[e.RowIndex];
var info = this.gvwList.Rows[e.RowIndex].DataBoundItem as PlayerInfo;
if (info != null)
{
row.Cells["Sex"].Value = info.Sex == 1 ? "男" : "女";//仍为数字
row.Cells["CountryID"].Value = bllCountry.GetCountryName(info.CountryID);//仍为数字
row.Cells["BelongTo"].Value = bllPlayerSpecialty.GetSpecialtys(info.PlayerID);//仍为数字
}
}