点击这里给我发消息 点击这里给我发消息

内容分页的第二种方法

添加时间:2010-5-12
    相关阅读: 项目

<table style="width: 100%">
            <tr>
                <td style="width: 100%; font-size: 9pt;">主题:<asp:DropDownList ID="ddl_VoteCode" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddl_VoteCode_SelectedIndexChanged" Width="190px">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td style="font-size: 9pt; width: 100%; text-align: center;" valign="top"><div style="OVERFLOW: auto; WIDTH: 224px; HEIGHT: 193px">
                      <asp:GridView ID="gv_vote" runat="server" AutoGenerateColumns="False" Width="220px" OnRowDataBound="gv_vote_RowDataBound" DataKeyNames="VoteCode,IsSignSelect" Height="193px">
                          <Columns>
                              <asp:TemplateField HeaderText="此主题的投票内容">
                              <ItemTemplate>
                              <%#DataBinder.Eval(Container.DataItem,"VoteName") %><asp:Panel runat="server" ID="ItemPanel" style="border: 1px solid #C0C0C0"></asp:Panel>
                              </ItemTemplate>
                                  <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />
                              </asp:TemplateField>
                          </Columns>
                      </asp:GridView></div>
                    <asp:ImageButton ID="Img_click" runat="server" ImageUrl="~/images/toupiao.jpg" border="0" OnClick="Img_click_Click" /></td>
            </tr>
        </table>

 

 

 #region 得到当前的投票主题
        private void BindSubjectData()
        {
            if (this.ddl_VoteCode.SelectedValue.ToString() != null)
            {
                DataTable BaseDt = VoteBaseDataDAL.GetListVoteName(this.ddl_VoteCode.SelectedValue.ToString());
                if (BaseDt.Rows.Count==0)
                {
                    this.Img_click.Visible = false;
                }
                else
                {
                    gv_vote.DataSource = VoteBaseDataDAL.GetListVoteName(this.ddl_VoteCode.SelectedValue.ToString());
                    gv_vote.DataBind();
                }

            }
        }
        #endregion

 

#region 得到当前主题下的项目
        protected void gv_vote_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string VoteCode = this.gv_vote.DataKeys[e.Row.RowIndex].Values[0].ToString();
                string IsSignSelect = this.gv_vote.DataKeys[e.Row.RowIndex].Values[1].ToString();

                Panel panel = (Panel)e.Row.FindControl("ItemPanel");
                if (panel != null)
                {
                    if (VoteCode.Length == 4)
                    {
                        if (IsSignSelect == "0")
                        {
                            RadioButtonList radiolist = new RadioButtonList();
                            radiolist.ID = "radiolist";                        ///或者radiolist.ID = "radio";
                            BindItemDataByRadio(radiolist, gv_vote.DataKeys[e.Row.RowIndex].Values[0].ToString());
                            panel.Controls.Add(radiolist);
                            if (radiolist.Items.Count < 1)
                            {
                                panel.Controls.Add(new LiteralControl("<font color='red'>没有投票内容</font>"));
                            }

                        }
                        else if (IsSignSelect == "1")
                        {
                            CheckBoxList checklist = new CheckBoxList();
                            checklist.ID = "checklist";
                            BindItemDataByCkeck(checklist, gv_vote.DataKeys[e.Row.RowIndex].Values[0].ToString());
                            panel.Controls.Add(checklist);
                            if (checklist.Items.Count < 1)
                            {
                                panel.Controls.Add(new LiteralControl("<font color='red'>没有投票内容</font>"));
                            }
                        }

                    }
                }
            }
        }
        #endregion

   #region 得到当前每个项下的内容(单选)
        private void BindItemDataByRadio(RadioButtonList radiolist, string ParentCode)
        {
            radiolist.DataSource = VoteBaseDataDAL.GetListVoteName(ParentCode);
            radiolist.DataTextField = "VoteName";
            radiolist.DataValueField = "VoteCode";
            radiolist.DataBind();
        }
        #endregion

  #region 得到当前项下的内容(多选)
        private void BindItemDataByCkeck(CheckBoxList checklist, string ParentCode)
        {
            checklist.DataSource = VoteBaseDataDAL.GetListVoteName(ParentCode);
            checklist.DataTextField = "VoteName";
            checklist.DataValueField = "VoteCode";
            checklist.DataBind();
        }
        #endregion

<asp:GridView ID="gv_vote" runat="server" AutoGenerateColumns="False" Width="220px" OnRowDataBound="gv_vote_RowDataBound" DataKeyNames="VoteCode,IsSignSelect" Height="193px">
主键
DataKeyNames="VoteCode,IsSignSelect"

咨询热线:020-85648757 85648755 85648616 0755-27912581 客服:020-85648756 0755-27912581 业务传真:020-32579052
广州市网景网络科技有限公司 Copyright◎2003-2008 Veelink.com. All Rights Reserved.
广州商务地址:广东省广州市黄埔大道中203号(海景园区)海景花园C栋501室
= 深圳商务地址:深圳市宝源路华丰宝源大厦606
研发中心:广东广州市天河软件园海景园区 粤ICP备05103322号 工商注册