Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Set Radiobuttonlist value in datagrid during edit

Last post 03-27-2008 3:51 PM by janetb. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 03-27-2008 3:51 PM

    • janetb
    • Top 500 Contributor
    • Joined on 10-07-2005
    • Addicted Member
    • Points 620

    Set Radiobuttonlist value in datagrid during edit

    Can anyone tell me what I'm doing wrong here? I keep getting "Object reference not set to an instance of an object." on the Edit line trying to set the value.  FYI - this is in a script tag NOT codebehind.  Thanks

     Datagrid:
    <asp:TemplateColumn HeaderText="News?" >
    <FooterTemplate><asp:RadioButtonList ID="radNews" Runat="Server" RepeatDirection="Horizontal"><asp:ListItem Text="True" Value="1" Selected="true" /><asp:ListItem Text="False" Value="0" /></asp:RadioButtonList></FooterTemplate>
    <ItemTemplate><%#Convert.ToBoolean(Container.DataItem("news"))%></ItemTemplate>
    <EditItemTemplate><asp:RadioButtonList ID="radNewsE" Runat="Server" RepeatDirection="Horizontal"><asp:ListItem Text="True" Value="1" /><asp:ListItem Text="False" Value="0" /></asp:RadioButtonList></EditItemTemplate>
    </asp:TemplateColumn>
    <asp:BoundColumn DataField="news" Visible="true" />

        Protected Sub dgList_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs  ) Handles dgList.ItemCommand
            lblMsg.Text = String.Empty
            If e.CommandName = "Edit" Then
                dgList.EditItemIndex = e.Item.ItemIndex
                CType(dgList.Items(e.Item.ItemIndex).FindControl("radNewE"), RadioButtonList).SelectedValue = e.Item.Cells(13).Text
                CType(dgList.Items(e.Item.ItemIndex).FindControl("radNewE"), RadioButtonList).DataBind()
            End If

    • Post Points: 5
Page 1 of 1 (1 items)