将gridview中的记录放入rdlc报告中

时间:2014-07-15 07:33:22

标签: c# asp.net gridview

我遇到了问题:

我已经从商店程序中填写了gridview。此gridview收到投诉,用户必须选择这些投诉是有效还是无效,然后在选择有效投诉后,必须在报告中显示。 简单来说,选择3个投诉作为有效并单击生成报告,它应包含这3个记录。

protected void btnSearch_Click(object sender, EventArgs e)
    {
        try
        {
            DateTime fromDate = DateTime.ParseExact(txtDateFrom.Text, "dd/MMM/yyyy", null);
            DateTime toDate = DateTime.ParseExact(txtDateTo.Text, "dd/MMM/yyyy", null);
            DataTable dt = ManageRecievedMessage.GetSmsComplaintsByDate(fromDate, toDate);
            if (dt.Rows.Count > 0)
            {

                GridViewSmsComplaints.DataSource = dt;
                GridViewSmsComplaints.DataBind();
                GridViewSmsComplaints.Visible = true;
            }
            else
            {

                dt.Rows.Add(dt.NewRow());
                GridViewSmsComplaints.DataSource = dt;
                GridViewSmsComplaints.DataBind();
                int totalcolums = GridViewSmsComplaints.Rows[0].Cells.Count;
                GridViewSmsComplaints.Rows[0].Cells.Clear();
                GridViewSmsComplaints.Rows[0].Cells.Add(new TableCell());
                GridViewSmsComplaints.Rows[0].Cells[0].ColumnSpan = totalcolums;
                GridViewSmsComplaints.Rows[0].Cells[0].Text = "No Data Found for this date combination";
                GridViewSmsComplaints.Visible = true;

            }
        }
        catch (Exception ex)
        {
            GridViewSmsComplaints.Visible = false;
            HiddenFieldSetMessage.Value = "NoDataForInput";
            HiddenFieldShowMessage.Value = "True";
        }

    }
    protected void GridViewSmsComplaints_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        //This Event is Triggered When Page is Changed in Gridview e.g. 1,2,3

        DateTime fromDate = DateTime.ParseExact(txtDateFrom.Text, "dd/MMM/yyyy", null);
        DateTime toDate = DateTime.ParseExact(txtDateTo.Text, "dd/MMM/yyyy", null);
        DataTable dt = ManageRecievedMessage.GetSmsComplaintsByDate(fromDate, toDate);

        if (dt.Rows.Count != 0)
        {
            GridViewSmsComplaints.PageIndex = e.NewPageIndex;
            GridViewSmsComplaints.DataSource = dt;
            GridViewSmsComplaints.DataBind();
            GridViewSmsComplaints.Visible = true;
        }
    }

    Date From:
                            <asp:TextBox ID="txtDateFrom" runat="server" ></asp:TextBox>
                            &nbsp;&nbsp; Date To:
                            <asp:TextBox ID="txtDateTo" runat="server"></asp:TextBox>
                            <asp:CalendarExtender ID="CalendarExtenderDateFrom"  Format="dd/MMM/yyyy" TargetControlID="txtDateFrom" 
                              runat="server"></asp:CalendarExtender>
                            <asp:CalendarExtender ID="CalendarExtenderDateTo"  Format="dd/MMM/yyyy" TargetControlID="txtDateTo" 
                              runat="server"></asp:CalendarExtender>

                            &nbsp;
   <span id="Save-Span">
    <asp:Button ID="btnSearch"  CssClass="btn btn-success" runat="server" Text="Search" 
      ValidationGroup="ValidationGroupTextboxes" ClientIDMode="Static" OnClick="btnSearch_Click" />
                            <br />
   <asp:GridView ID="GridViewSmsComplaints" AllowPaging="True" PageSize="4" runat="server" OnPageIndexChanging="GridViewSmsComplaints_PageIndexChanging" AutoGenerateColumns="False" CssClass="mGrid" BorderColor="#333333"  Width="550px">
               <Columns>
                    <asp:BoundField HeaderText="ID" DataField="ID" /> 
                    <asp:BoundField HeaderText="Recieving Date" DataField="RecievingDate" />  
                    <%--<asp:BoundField HeaderText="ToMobileNo" DataField="ToMobileNo" />  --%>
                    <asp:BoundField HeaderText="FromMobileNo" DataField="FromMobileNo" /> 
                    <asp:BoundField HeaderText="Message" DataField="Message" >   
                     <ItemStyle Wrap="True" />
                    </asp:BoundField>
                    <asp:TemplateField HeaderText="IsComplaint">
                     <ItemTemplate>
                       <asp:DropDownList ID="ddlValidity" runat="server">
                           <asp:ListItem Value="1" Text="Valid"></asp:ListItem>
                           <asp:ListItem Value="0" Text="InValid"></asp:ListItem>
                       </asp:DropDownList>
                     </ItemTemplate>
                    </asp:TemplateField>
               </Columns>
    </asp:GridView>

我知道报告等但是如何在报告中选择有效记录?

0 个答案:

没有答案