I have a datagrid that has an Add link in the footer with textboxes
for adding of the items in the grid. I've put in required field
validators within the grid so when users edit the grid I have the
correct info. When someone edits a line in the grid and then clicks
the update - it causes the validation to be performed not only on
the line they are editing but also on the text boxes of the Add
function.
I've tried to disable the causes validation property of the control
in the Datagrid edit routine - but must not be doing correctly
because I'm getting object not set to instance of object error.
Here is my aspx code:
<td width="70%"><asp:datagrid id="dgUser" runat="server"
AutoGenerateColumns="False" ShowFooter="True" PageSize="25"
<asp:EditCommandColumn ButtonType="LinkButton"
UpdateText="Update" CancelText="Cancel"
EditText="Edit"></asp:EditCommandColumn>
<asp:ButtonColumn Text="Delete"
CommandName="Delete"></asp:ButtonColumn>
<asp:TemplateColumn HeaderText="User ID">
<ItemTemplate>
<asp:Label id=lblUserID runat="server" Font-Size="X-
Small" text='<%#Container.dataitem("personID")%>' Height="20px">
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton id="lnkbtnAddUser" runat="server"
Font-Size="X-Small" Height="20px" CausesValidation="False"
CommandName="Insert">Add
User</asp:LinkButton>
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="First Name">
<ItemTemplate>
<asp:Label id=lblFirstName runat="server" Font-
Size="X-Small" Width="100px" Height="20px" text='<%
#Container.dataitem("firstname")%>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="txtNewFirstName" runat="server"
Font-Size="X-Small" Width="100px" Height="20px"></asp:TextBox>
<asp:RequiredFieldValidator id="rfvAddFName"
runat="server" ControlToValidate="txtNewFirstName" Display="Dynamic"
ErrorMessage="*">First Name is
required</asp:RequiredFieldValidator>
</FooterTemplate>
<EditItemTemplate>
<asp:TextBox id=txtFirstName runat="server" Font-
Size="X-Small" Width="100px" Height="20px" text='<%
#Container.dataitem("firstname")%>'>
</asp:TextBox>
<asp:RequiredFieldValidator id="rfvFName"
runat="server" Font-Size="X-Small" ControlToValidate="txtFirstName"
Display="Dynamic" ErrorMessage="*">First
Name required</asp:RequiredFieldValidator>
</EditItemTemplate>
Code-behind:
Private Sub dgUser_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgUser.EditCommand
lblError.Text = " "
Dim rfvAddFName As RequiredFieldValidator
rfvAddFName = e.Item.Cells(3).FindControl("rfvAddFName")
rfvAddFName.Enabled = False
dgUser.DataKeyField = "personID"
dgUser.EditItemIndex = e.Item.ItemIndex
Dim dsUserStatus As DataSet = GetDataSet(False)
BindGrid(dsUserStatus)
End Sub
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/