日期:2014-05-17 浏览次数:20426 次
select a.Name,a.Sex,b.Address,b.Mail from TableA a,TableB b where 两表的公共条件 最后执行的ds结果会是这样子 NAME SEX ADDRESS MAIL 张三 男 北京 123@sina.com 然后在你的gridview前台绑定的时候就分别直接绑定NAME SEX ADDRESS MAIL就可以了
------解决方案--------------------
<asp:GridView ID="GridView1" runat="server"> <asp:TemplateField HeaderText="性别"> <ItemTemplate> <asp:Label ID="lblSex" runat="server" Text='<%# Eval("sex") %>'></asp:Label> <asp:RadioButtonList ID="rblSex" runat="server"> </asp:RadioButtonList> <asp:HiddenField ID="id" runat="server" Value='<%# Eval("id") %>' /> </asp:TemplateField> </asp:GridView> C# code protected void gvUser_RowDataBound(object sender, GridViewRowEventArgs e) { //判断是否是数据项 if (e.Row.RowType == DataControlRowType.DataRow) { //判断是否是编辑状态或交替行 if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate) { RadioButtonList rblSex = (RadioButtonList)e.Row.FindControl("rblSex");//找到RadioButtonList string id =( (HiddenField)e.Row.FindControl("rblSex")).Value;//找到关联键 rblSex.DataSource = xxxManager.GetXXById(id);//绑定RadioButtonList rblSex.DataBind(); } } }