ClsCon con = new ClsCon();
con.CondDatabase();
DataSet ds = new DataSet();
string yearterm;
if (comboBox1.SelectedIndex != -1)
{
yearterm = this.comboBox1.SelectedValue.ToString();
string sql = "select yeartermid,courid,courname,MergClassName,courorder,reuptype from t_TeachTask where yeartermid = '" + yearterm + "'";
SqlDataAdapter da = new SqlDataAdapter(sql, con.conn);
da.Fill(ds, "Task");
dataGridView2.DataSource = ds.Tables["Task"]; }
请问:红色字体部分是整表绑定,如果我只想绑定数据表的一部分列怎么办?并且列名如何设置?如果我在设计界面定好了列名,那么请问,我如何把需要的结果和已经定好的列绑定在一起呢?
如:
<asp:TemplateField HeaderText="书名"> //设置列名
<ItemTemplate>
<%# Eval("courname")%>//绑定值
</ItemTemplate> </asp:TemplateField>
兄弟不行吧.我本来就是用代码绑定的DataSource,你让我在属性里面设置,这能行吗?