Hey all,

guys I hav to use calendar control in a data grid.. But the events for tha calendar(selection change n others ) are not getting fired...

i am using datagrid_itemcommand and i am searching for the command name but the calendar control doesnt have command name.

how i can catch the calender event and get the select date in a textbox beside the calendar.

sam

Recommended Answers

All 11 Replies

hi
i'm also in need of a calendar control in a datagrid urgently
can u please tel me how do u includecalendar in datagrid
thanks in advance
i need it in C# asp.net

Hey all,

guys I hav to use calendar control in a data grid.. But the events for tha calendar(selection change n others ) are not getting fired...

i am using datagrid_itemcommand and i am searching for the command name but the calendar control doesnt have command name.

how i can catch the calender event and get the select date in a textbox beside the calendar.

sam

dude

i fixed this problem by including a calendar javascript.

u have to add item template in the datagrid then add the calender. if u click on the calender it will set the value in a textbox.

This war is faster and no need to include calendar control.

sam

hi
i'm also in need of a calendar control in a datagrid urgently
can u please tel me how do u includecalendar in datagrid
thanks in advance
i need it in C# asp.net[/quote

I am also in need of this one. I can get the popup calendar and it did return the selected date in the Control text field "txtEffDate" in EditTemplate but when I try to retrieve using :
Dim EffDate As String = Convert.ToString(CType(e.Item.FindControl("txtEffDate"), TextBox).Text) in the Update proc , it did not give me the datevalue which I saw on the screen? Please someone help me with this , I already spent 2 days on this one already....

hi can u tel me how could u catch the selected date from te calendar into the textbox inside grid

dude

i fixed this problem by including a calendar javascript.

u have to add item template in the datagrid then add the calender. if u click on the calender it will set the value in a textbox.

This war is faster and no need to include calendar control.

sam

Hi i am also having the same problem .
Can u tell me how to retrieve the selected date from a calendar inside a datagrid.?

just use any javascript calender control rather than .net control .and usage details willl based on control u r gng to use.so read the manual before using js calender .

Hi i have added a text box and a hyperlink in my template column. When i click on the hyperlink I want the calendar control to be dispalyed in a pop up window and i should be able to get the selected date. Can u tell me how to do this and the java script??

hi,

you can try like this

<asp:GridView ID="gdview"  runat="server" ShowFooter="true" AutoGenerateColumns="False"  DataKeyNames="CategoryID"    >
        <Columns>
            <asp:BoundField HeaderText="Category Name" DataField="CategoryName" SortExpression="CategoryName" >
                <ItemStyle Height="20px" Width="150px" />
            </asp:BoundField>
            <asp:TemplateField>
            <ItemTemplate>
            <asp:Calendar ID="id1" runat="server"  OnSelectionChanged="id1_SelectionChanged"></asp:Calendar>
            
            </ItemTemplate>
            
            </asp:TemplateField>

                   </Columns>
 

 </asp:GridView>

in code behind:

 protected void Page_Load(object sender, EventArgs e)
    {

        if (!Page.IsPostBack)
        {
            bindgrid();
          

        }

    }

    public void bindgrid()
    {
        SqlConnection conn = new SqlConnection("Data Source='localhost';Initial Catalog='Northwind';Integrated Security=SSPI;Persist Security Info=False ");
        SqlCommand cmd = new SqlCommand("select CategoryName,CategoryID from Categories ", conn);

        SqlDataAdapter da = new SqlDataAdapter("", conn);
        da.SelectCommand = new SqlCommand("select CategoryName,CategoryID from Categories", conn);
        DataSet ds = new DataSet();
        da.Fill(ds, "data");
        gdview.DataSource = ds.Tables[0].DefaultView;
        gdview.DataBind();


    }
    protected void id1_SelectionChanged(object sender, EventArgs e)
    {
        Calendar cal = new Calendar();
        GridViewRow dgrow = (GridViewRow)cal.NamingContainer;

    }

You can use _Rowdatbound event you will be get the answer

EX:

Protected Sub GridView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView.RowDataBound
---------------
---------------------

End sub

DataGrid.ItemCommand Event Occurs when any button is clicked in the DataGrid control.
So to handle event of any other control binded to grid you can use controls own event handler.
In this example you need to attach event handler to calendar event
i.e
aspx page:

<ItemTemplate>
            <asp:Calendar ID="calendarCtr" runat="server"  OnSelectionChanged="calendarCtr_SelectionChanged"></asp:Calendar>
</ItemTemplate>

code behind create:

protected void calendarCtr_SelectionChanged(object sender, EventArgs e)
{code.....}

Thanks... It worked...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.