<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table >
            <tr>
                <th>
                    类型周期:
                </th>
                <td>
                    <asp:CheckBoxList ID="ck" runat="server" AutoPostBack="true" 
                        RepeatDirection="Horizontal" onselectedindexchanged="ck_SelectedIndexChanged" >
                        <asp:ListItem Value="0" >季</asp:ListItem>
                        <asp:ListItem Value="1">年</asp:ListItem>
                        <asp:ListItem Value="2">月</asp:ListItem>
                        <asp:ListItem Value="3">日</asp:ListItem>
                    </asp:CheckBoxList>
                </td>
            </tr>
        </table>
        <table>
            <tr>
                <td>
                    <asp:GridView ID="gvw" runat="server" header AutoGenerateColumns="False">
                        <Columns>
                            <asp:TemplateField HeaderText="序号">
                                <ItemTemplate >
                                    <%#Container.DataItemIndex+1 %>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="类型周期">
                                <ItemTemplate>
                                    <asp:Label ID="typename" runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="对标值">
                                <ItemTemplate>
                                    <asp:CheckBoxList ID="cklist" runat="server" RepeatDirection="Horizontal">
                                        <asp:ListItem Value="0">一流线</asp:ListItem>
                                        <asp:ListItem Value="1">二流线</asp:ListItem>
                                        <asp:ListItem Value="2">三流线</asp:ListItem>
                                    </asp:CheckBoxList>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
我想选择后期类型后自动加载相应的值到gridview中去,不知道具体怎么弄了,有哪位大侠知道,先做添加功能,然后当我修改的时候,在一列中有checklist的集合,我怎么去判断后显示出来;gridview datatable 

解决方案 »

  1.   


    DataTable dt= new DataTable();
    DataRow dr=dt.NewRow();
    dr["typename"]= "值";
    dt.Rows.Add(dr);
    dt.AcceptChanges();
    gvw.DataSource=dt;
    gvw.DataBind();
      

  2.   


    不行,dr[“typename”]不属于表,这个周期类型就是复选框的值 ,但它修改的时候是从数据库中获取的,怎么弄呢
      

  3.   

    dr["typeName"] 是代表数据绑定到控件上对应你的代码给出的名字
          <asp:Label ID="typename" runat="server"></asp:Label>你是绑定到这个上面 所以我才写的TypeName至于绑定的Eval("typeName") 你自己应该知道些吧?