Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
i have a calender control and a grid view.
Now when i select the date in the calender control i want the records on that date will be displayed in that gridview can i do that?
Posted 8-Feb-13 19:52pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Try this :
 
 
<asp:textbox id="TextBox1" runat="server" autopostback="True" xmlns:asp="#unknown">
       ontextchanged="TextBox1_TextChanged"></asp:textbox>
 


and code ...
 
 
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
   // bind your gridview with the where clause of date 
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Yes its very easy....
 
create stored procedure with following select statement
 
select * from tablename where Date=@Date
 

and pass your text box date as parameter from your code
 
i hope your understood...
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

yes you can do it
 

 
<div style="float:left;width:700px " >
     From Date &nbsp;
            <asp:TextBox ID="txtdate" BorderColor="#29447E" BorderStyle="Solid" BorderWidth="1px" width="110px" runat="server"  EnableTheming="False"></asp:TextBox>
                <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/Calender.jpg" Height="16px" Width="16px"
                    ImageAlign="TextTop" CausesValidation="False" />
                <asp:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtdate" Enabled="True"  CssClass="blue" PopupPosition="BottomRight" PopupButtonID="ImageButton1" Format="dd-MMM-yyyy">
                </asp:CalendarExtender>
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                        ErrorMessage="Please Choose Date" ControlToValidate="txtdate" Display="Dynamic" ForeColor="Red">
                    </asp:RequiredFieldValidator>
 
                 &nbsp;
    To Date &nbsp;
        <asp:TextBox ID="txttodate" BorderColor="#29447E" BorderStyle="Solid" BorderWidth="1px" width="110px" runat="server"  EnableTheming="False"></asp:TextBox>
                <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/images/Calender.jpg" Height="16px" Width="16px" ImageAlign="TextTop" CausesValidation="False" />
                <asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txttodate" Enabled="True"  CssClass="blue" PopupPosition="BottomRight" PopupButtonID="ImageButton2" Format="dd-MMM-yyyy">
                </asp:CalendarExtender>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2"
                        runat="server" ErrorMessage="Please Choose Date" ControlToValidate="txttodate" Display="Dynamic" ForeColor="Red">
                    </asp:RequiredFieldValidator>
                    &nbsp;&nbsp;
 <asp:Button ID="btnsubmit" runat="server" Text="View Report" CssClass="tab"
         onclick="btnsubmit_Click" />
       
</div>
<br /><br />
<asp:Panel ID="Panel1" runat="server" Width="800px" ScrollBars="Horizontal" style =" max-height:500px" >
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
 
 <asp:GridView ID="GridView1" runat="server" AllowPaging="True" OnRowDataBound="GridView1_RowDataBound" PageSize="16" DataKeyNames="Cr_No" DataSourceID=&uot;SqlDataSource2" PagerSettings-FirstPageText="First" PagerSettings-LastPageText="Last" PagerSettings-Mode="NumericFirstLast">
                             
                                <PagerStyle CssClass="PagerStyle" />
                            <Columns>
                              <asp:TemplateField HeaderText="Cr Date">
                                <ItemTemplate>
                                    <asp:Label ID="crdate" runat="server" Text='<%# Bind("Cr_Dt","{0:dd-MMM-yyyy}") %>'></asp:Label>
                                </ItemTemplate>
  <ItemStyle HorizontalAlign="Center" Width="40px"  />
  <HeaderStyle CssClass="headerstylelist" HorizontalAlign="Center"  Width="40px" />
                         </asp:TemplateField>        
                                
                            </Columns>
                        </asp:GridView>
                    </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="btnsubmit"  EventName="Click" />
                        </Triggers>
    </asp:UpdatePanel>
 
                        <asp:SqlDataSource ID="SqlDataSource2" runat="server"
                            ConnectionString="<%$ ConnectionStrings:hospital %>"
                            SelectCommand="SELECT [Cr_No], [Cr_Dt] FROM [opdreport] WHERE (([Cr_Dt] >= @fromdate) AND ([Cr_Dt] <= @todate))"  >
                            <SelectParameters>
                              <asp:ControlParameter Name="fromdate" ControlID="txtdate" PropertyName="Text" Type="DateTime"     />
                                <asp:ControlParameter Name="todate" ControlID="txttodate" PropertyName="Text" Type="DateTime"     />
                            </SelectParameters>
                        </asp:SqlDataSource>
                         </asp:Panel>
  Permalink  
v2
Comments
veenusethi at 9-Feb-13 1:33am
   
Or you can use also this if only one date is available

<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:hospital %>"
SelectCommand="SELECT [Cr_No], [Cr_Dt] FROM [opdreport] WHERE ([Cr_Dt] = @fromdate )" >
<SelectParameters>
<asp:ControlParameter Name="fromdate" ControlID="txtdate" PropertyName="Text" Type="DateTime" />

</SelectParameters>
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

at first take a textbox and add calender extender from ajax or use java script to add calender on it... and set textbox 's autopostback true and set textbox textchange event true...
 
like..
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"
       ontextchanged="TextBox1_TextChanged"></asp:TextBox>
 
and write code for gridview here...
 

protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
 
    }
 
using whare clase ....
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 5,170
1 DamithSL 4,357
2 Maciej Los 3,750
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,851


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 9 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100