Calendar in a DataGrid column

M

Mike

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
 
M

Mike

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

Thanks a lot.
Mike

--
Michael
Sure. Templated column.

Eliyahu
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
 
E

Eliyahu Goldin

Sure. Templated column.

Eliyahu
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

S. Justin Gengo

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
Thanks, but is there any sample or article that you are aware of?
I am new to asp.net.

Thanks a lot.
Mike

--
Michael
Sure. Templated column.

Eliyahu
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top