![]() |
|
|
|
#1 |
|
I have a GridView bound to a DataSource. The GridView only has 1 column that
can be edited. If I click on the Edit LinkButton on a row with data in the editable column then the RowDatabound event works fine. If that editable column is NULL then it doesn't fire. This seems really strange. Can anyone see what might be wrong? The RowDatabound event code is below. After that is the markup for the GridView column template. Thanks in advance. -David Protected Sub gvPartsOnOrder_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvPartsOnOrder.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowState = DataControlRowState.Edit Then 'row is in edit mode Dim tb As TextBox = Page.Master.FindControl("txtMsg") tb.Text = "I am in edit mode" If IsDBNull(DataBinder.Eval(e.Row.DataItem, "PartEstimatedDeliveryDate")) Then 'DateTime is empty so enable the mask Dim obj As Object = e.Row.FindControl("MaskedEditExtender1") obj.Enabled = True End If End If If e.Row.RowState = DataControlRowState.Normal _ Or e.Row.RowState = DataControlRowState.Alternate Then If IsDBNull(DataBinder.Eval(e.Row.DataItem, "PartEstimatedDeliveryDate")) Then e.Row.Cells(4).BackColor = Drawing.Color.Red Else Dim dtEstDelivery As DateTime = _ Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, "PartEstimatedDeliveryDate")) If dtEstDelivery < System.DateTime.Today Then e.Row.Cells(4).BackColor = Drawing.Color.Red End If End If End If End If End Sub <asp:TemplateField HeaderText="Estimated<br />Delivery<br />Date/Time" SortExpression="PartEstimatedDeliveryDate"> <EditItemTemplate> <asp:TextBox ID="txtPartEstimatedDeliveryDate" runat="server" Text='<%# Bind("PartEstimatedDeliveryDate") %>'></asp:TextBox> <cc1:MaskedEditExtender ID="MaskedEditExtender1" runat="server" AcceptAMPM="True" TargetControlID="txtPartEstimatedDeliveryDate" MaskType="DateTime" Mask="99/99/9999 99:99" AutoComplete="False" UserDateFormat="MonthDayYear" Enabled="False"> </cc1:MaskedEditExtender> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("PartEstimatedDeliveryDate","{0:M/d/yyyy hh:mm tt}") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> David C |
|
|
|
|
#2 |
|
Posts: n/a
|
One other thing I noticed is that the code works on every other row. Hope
this helps. David "David C" <> wrote in message news:... >I have a GridView bound to a DataSource. The GridView only has 1 column >that can be edited. If I click on the Edit LinkButton on a row with data >in the editable column then the RowDatabound event works fine. If that >editable column is NULL then it doesn't fire. This seems really strange. >Can anyone see what might be wrong? The RowDatabound event code is below. >After that is the markup for the GridView column template. Thanks in >advance. > > -David > > > Protected Sub gvPartsOnOrder_RowDataBound(ByVal sender As Object, ByVal > e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles > gvPartsOnOrder.RowDataBound > If e.Row.RowType = DataControlRowType.DataRow Then > If e.Row.RowState = DataControlRowState.Edit Then > 'row is in edit mode > Dim tb As TextBox = Page.Master.FindControl("txtMsg") > tb.Text = "I am in edit mode" > If IsDBNull(DataBinder.Eval(e.Row.DataItem, > "PartEstimatedDeliveryDate")) Then > 'DateTime is empty so enable the mask > Dim obj As Object = > e.Row.FindControl("MaskedEditExtender1") > obj.Enabled = True > End If > End If > If e.Row.RowState = DataControlRowState.Normal _ > Or e.Row.RowState = DataControlRowState.Alternate Then > If IsDBNull(DataBinder.Eval(e.Row.DataItem, > "PartEstimatedDeliveryDate")) Then > e.Row.Cells(4).BackColor = Drawing.Color.Red > Else > Dim dtEstDelivery As DateTime = _ > Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, > "PartEstimatedDeliveryDate")) > If dtEstDelivery < System.DateTime.Today Then > e.Row.Cells(4).BackColor = Drawing.Color.Red > End If > End If > End If > End If > > End Sub > > > <asp:TemplateField HeaderText="Estimated<br />Delivery<br > />Date/Time" SortExpression="PartEstimatedDeliveryDate"> > <EditItemTemplate> > <asp:TextBox ID="txtPartEstimatedDeliveryDate" > runat="server" Text='<%# Bind("PartEstimatedDeliveryDate") > %>'></asp:TextBox> > <cc1:MaskedEditExtender ID="MaskedEditExtender1" > runat="server" AcceptAMPM="True" > > TargetControlID="txtPartEstimatedDeliveryDate" MaskType="DateTime" > Mask="99/99/9999 99:99" > AutoComplete="False" > UserDateFormat="MonthDayYear" Enabled="False"> > </cc1:MaskedEditExtender> > </EditItemTemplate> > <ItemTemplate> > <asp:Label ID="Label1" runat="server" Text='<%# > Bind("PartEstimatedDeliveryDate","{0:M/d/yyyy hh:mm tt}") %>'></asp:Label> > </ItemTemplate> > </asp:TemplateField> > > David C |
|
|
|
#3 |
|
Posts: n/a
|
I figured it out. RowState is a total of the values in normal and alternate
rows so I had to add them together. David "David C" <> wrote in message news:... >I have a GridView bound to a DataSource. The GridView only has 1 column >that can be edited. If I click on the Edit LinkButton on a row with data >in the editable column then the RowDatabound event works fine. If that >editable column is NULL then it doesn't fire. This seems really strange. >Can anyone see what might be wrong? The RowDatabound event code is below. >After that is the markup for the GridView column template. Thanks in >advance. > > -David > > > Protected Sub gvPartsOnOrder_RowDataBound(ByVal sender As Object, ByVal > e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles > gvPartsOnOrder.RowDataBound > If e.Row.RowType = DataControlRowType.DataRow Then > If e.Row.RowState = DataControlRowState.Edit Then > 'row is in edit mode > Dim tb As TextBox = Page.Master.FindControl("txtMsg") > tb.Text = "I am in edit mode" > If IsDBNull(DataBinder.Eval(e.Row.DataItem, > "PartEstimatedDeliveryDate")) Then > 'DateTime is empty so enable the mask > Dim obj As Object = > e.Row.FindControl("MaskedEditExtender1") > obj.Enabled = True > End If > End If > If e.Row.RowState = DataControlRowState.Normal _ > Or e.Row.RowState = DataControlRowState.Alternate Then > If IsDBNull(DataBinder.Eval(e.Row.DataItem, > "PartEstimatedDeliveryDate")) Then > e.Row.Cells(4).BackColor = Drawing.Color.Red > Else > Dim dtEstDelivery As DateTime = _ > Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, > "PartEstimatedDeliveryDate")) > If dtEstDelivery < System.DateTime.Today Then > e.Row.Cells(4).BackColor = Drawing.Color.Red > End If > End If > End If > End If > > End Sub > > > <asp:TemplateField HeaderText="Estimated<br />Delivery<br > />Date/Time" SortExpression="PartEstimatedDeliveryDate"> > <EditItemTemplate> > <asp:TextBox ID="txtPartEstimatedDeliveryDate" > runat="server" Text='<%# Bind("PartEstimatedDeliveryDate") > %>'></asp:TextBox> > <cc1:MaskedEditExtender ID="MaskedEditExtender1" > runat="server" AcceptAMPM="True" > > TargetControlID="txtPartEstimatedDeliveryDate" MaskType="DateTime" > Mask="99/99/9999 99:99" > AutoComplete="False" > UserDateFormat="MonthDayYear" Enabled="False"> > </cc1:MaskedEditExtender> > </EditItemTemplate> > <ItemTemplate> > <asp:Label ID="Label1" runat="server" Text='<%# > Bind("PartEstimatedDeliveryDate","{0:M/d/yyyy hh:mm tt}") %>'></asp:Label> > </ItemTemplate> > </asp:TemplateField> > > David C |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: Possible motherboard issue | sandy58 | Computer Support | 5 | 03-07-2009 11:22 PM |
| Re: Possible motherboard issue | Centre Parting | Computer Support | 0 | 03-03-2009 12:49 PM |
| Major ActiveX Domain issue. NOT LOCAL PC ISSUE | joe.valentine@gmail.com | Computer Support | 8 | 02-06-2006 09:03 PM |
| DHCP fails on wireless networks, Is KB313896 still an issue? | =?Utf-8?B?Q2hyaXMgVGFuZ2Vy?= | Wireless Networking | 6 | 08-23-2004 03:55 PM |
| Win2K SP4 - what's the verdict? | Max Quordlepleen | Computer Support | 6 | 09-16-2003 11:23 AM |