Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Calendar in a DataGrid column

Reply
Thread Tools

Calendar in a DataGrid column

 
 
Mike
Guest
Posts: n/a
 
      07-12-2004
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

 
Reply With Quote
 
 
 
 
Mike
Guest
Posts: n/a
 
      07-12-2004
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" <(E-Mail Removed)> wrote in message news:#(E-Mail Removed)...
Sure. Templated column.

Eliyahu
"Mike" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
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

 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      07-12-2004
Sure. Templated column.

Eliyahu
"Mike" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
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

 
Reply With Quote
 
S. Justin Gengo
Guest
Posts: n/a
 
      07-12-2004
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" <(E-Mail Removed)> wrote in message news:%(E-Mail Removed)...
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" <(E-Mail Removed)> wrote in message news:#(E-Mail Removed)...
Sure. Templated column.

Eliyahu
"Mike" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
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

 
Reply With Quote
 
Saravana [MVP]
Guest
Posts: n/a
 
      07-14-2004
Check out this article,
http://www.microsoft.com/india/msdn/...ndarinASP.aspx

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



"Mike" <(E-Mail Removed)> wrote in message news:#(E-Mail Removed)...
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" <(E-Mail Removed)> wrote in message news:#(E-Mail Removed)...
Sure. Templated column.

Eliyahu
"Mike" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bind a dropdown in a column in a datagrid based on the dropdown value selected in another column of the datagrid. vishnu ASP .Net 1 03-25-2006 01:24 PM
Calendar within DataGrid Edit Control or Template Column keal75 ASP .Net Datagrid Control 0 11-10-2005 12:38 AM
how do i access a dropdownlists selected value in a datagrid edititemtemplate column from the selectedindexchanged event of another dropdownlist in a datagrid edititemtemplate column Dave M ASP .Net Datagrid Control 0 12-14-2004 11:53 AM
Add column to the last column of Datagrid Hai Nguyen ASP .Net 0 01-16-2004 10:10 PM
How to bind a db image column (byte array) to a datagrid column? Jim Hammond ASP .Net 1 11-26-2003 12:55 AM



Advertisments