Calendar in a DataGrid column

Discussion in 'ASP .Net' started by Mike, Jul 12, 2004.

  1. Mike

    Mike Guest

    Hi,

    Is there a possibility to have one of the Web Control Datagrid's column as a Calendar when editing data? Any resources on this subject?

    Thanks

    Mike
     
    Mike, Jul 12, 2004
    #1
    1. Advertising

  2. Mike

    Mike Guest

    Thanks, but is there any sample or article that you are aware of?
    I am new to asp.net.

    Thanks a lot.
    Mike

    --
    Michael
    "Eliyahu Goldin" <> wrote in message news:#...
    Sure. Templated column.

    Eliyahu
    "Mike" <> wrote in message news:...
    Hi,

    Is there a possibility to have one of the Web Control Datagrid's column as a Calendar when editing data? Any resources on this subject?

    Thanks

    Mike
     
    Mike, Jul 12, 2004
    #2
    1. Advertising

  3. Sure. Templated column.

    Eliyahu
    "Mike" <> wrote in message news:...
    Hi,

    Is there a possibility to have one of the Web Control Datagrid's column as a Calendar when editing data? Any resources on this subject?

    Thanks

    Mike
     
    Eliyahu Goldin, Jul 12, 2004
    #3
  4. Mike,

    This code uses a templated column to place a checkbox in a datagrid. It also shows how to find out which checkbox in the datagrid was clicked. I believe you'll need to do something similar for your calendar when it posts back.

    I hope it helps:


    How to reference a checkbox or radiobutton, etc. in a DataGrid


    How to loop through a datagrid to see if a checkbox in a column is checked.

    Sample Code:

    First here's the grid as a reference: (I'm not showing how the data gets
    bound to it.)


    <asp:datagrid id="DataGrid1" runat="server" >
    <columns>
    <asp:templatecolumn headertext="Correct">
    <itemtemplate>
    <asp:checkbox autopostback="True"
    oncheckedchanged="DataGridCheckBox_Changed" id="checkbox" runat="server"
    visible="True"></asp:checkbox>
    </itemtemplate>
    </asp:templatecolumn>
    <asp:boundcolumn datafield="Answer"
    headertext="Answer"></asp:boundcolumn
    </columns>
    </asp:datagrid>





    And here's how to get the row's ItemIndex when you click the checkbox:
    (Note: the checkbox above is set to autopostback.)


    Protected Sub DataGridCheckBox_Changed(ByVal sender As System.Object, ByVal
    e As System.EventArgs)
    '---Get the checkbox the user just clicked
    Dim cbSent As CheckBox = CType(sender, CheckBox)

    '---Prepare to loop through the datagrid
    Dim mintRowsCount, mintRowsLoop, mintCountChecked, mintAllowChecked
    As Integer
    Dim cbCurrent As CheckBox
    Dim mintRowIndexFound As Integer

    '---Get the number of rows in the datagrid
    mintRowsCount = DataGrid1.Items.Count() - 1

    '---Loop through each row
    For mintRowsLoop = 0 To mintRowsCount
    '---Get the current row's checkbox
    cbCurrent =
    CType(DataGrid1.Items(mintRowsLoop).FindControl("checkbox"), CheckBox)

    '---Compare the current checkbox to the one clicked if they
    match this is the row!
    If cbCurrent.Equals(cbSent) Then
    '---Get the row's Index
    mintRowIndexFound =
    CInt(DataGrid1.Items(mintRowsLoop).ItemIndex)

    '---Exit the loop
    Exit For
    End If
    Next

    Response.Write(mintRowIndexFound.ToString)
    End Sub

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
    "Mike" <> wrote in message news:%...
    Thanks, but is there any sample or article that you are aware of?
    I am new to asp.net.

    Thanks a lot.
    Mike

    --
    Michael
    "Eliyahu Goldin" <> wrote in message news:#...
    Sure. Templated column.

    Eliyahu
    "Mike" <> wrote in message news:...
    Hi,

    Is there a possibility to have one of the Web Control Datagrid's column as a Calendar when editing data? Any resources on this subject?

    Thanks

    Mike
     
    S. Justin Gengo, Jul 12, 2004
    #4
  5. Check out this article,
    http://www.microsoft.com/india/msdn/articles/PopupCalendarinASP.aspx

    --
    Saravana
    Microsoft MVP - ASP.NET
    www.extremeexperts.com



    "Mike" <> wrote in message news:#...
    Thanks, but is there any sample or article that you are aware of?
    I am new to asp.net.

    Thanks a lot.
    Mike

    --
    Michael
    "Eliyahu Goldin" <> wrote in message news:#...
    Sure. Templated column.

    Eliyahu
    "Mike" <> wrote in message news:...
    Hi,

    Is there a possibility to have one of the Web Control Datagrid's column as a Calendar when editing data? Any resources on this subject?

    Thanks

    Mike
     
    Saravana [MVP], Jul 14, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Hammond
    Replies:
    1
    Views:
    3,669
    bruce barker
    Nov 26, 2003
  2. Hai Nguyen
    Replies:
    0
    Views:
    411
    Hai Nguyen
    Jan 16, 2004
  3. Dexter
    Replies:
    1
    Views:
    432
    Eliyahu Goldin
    Jan 18, 2005
  4. John E.
    Replies:
    3
    Views:
    4,494
    masoud bayan
    Mar 25, 2005
  5. keal75

    Calendar within DataGrid Edit Control or Template Column

    keal75, Nov 10, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    157
    keal75
    Nov 10, 2005
Loading...

Share This Page