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("c heckbox"), 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" <no****@nospam.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
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" <re*************@monarchmed.com> wrote in message news:#0*************@tk2msftngp13.phx.gbl...
Sure. Templated column.
Eliyahu
"Mike" <no****@nospam.com> wrote in message news:uB**************@TK2MSFTNGP10.phx.gbl...
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