I don't know why this is happening. I have a radiobuttonList on my page and a datagrid. Based on the selection of Class number (1 or 2), the datagrid is populated, which works fine. Initially, the class number 1 populates and I can edit/update/delete
without any problems on this. When I switch to Class # 2, the items appear correctly; however, when I tried to Edit and Update an item, it does not call the Update command. Any ideas as to what's causing this when I switch to Class # 2?
I'm not using any panels....it's working fine when the page loads initially when the default value in radiobutton is "1", which is Class 1. When I change to selected value 2, the textboxes come up when clicking on edit, however, when clicking on "Update",
it does not actually go through the Update procedure. The Cancel and Delete command also work fine, just the Update doesn't.
In the pageload, I have the following code related to the datagrid:
If Not Page.IsPostBack Then BindDataGridCaseload() End If
Sub BindDataGridCaseload() If Not Request.Params("ClassNumber") = "" Then ClassNumber = CType(Request.Params("ClassNumber"), Integer) Else ClassNumber = 1 End If connection.Open() Dim ds As Data.DataSet = New Data.DataSet() Dim objAdapter As New SqlDataAdapter("SELECT * FROM CaseloadProfile WHERE PAID= " & PAID & "AND " & "Dropped=" & 0 & "AND " & "ClassNumber=" & ClassNumber & "", connection) objAdapter.Fill(ds, "CaseloadProfile") Me.dgCaseload.DataSource = ds.Tables("CaseloadProfile").DefaultView dgCaseload.DataBind() connection.Close() SetFocus(dgCaseload) End Sub
Private Sub dgCaseload_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgCaseload.UpdateCommand
Dim Intid As Integer
Dim txtName As TextBox
Dim txtPrimaryLanguage As TextBox
Dim tmpName, tmpRosterNumber, tmpPrimaryLanguage As String
Intid = dgCaseload.DataKeys(e.Item.ItemIndex)
txtName = e.Item.FindControl("txtName")
txtRosterNumber = e.Item.FindControl("txtRosterNumber")
txtPrimaryLanguage = e.Item.FindControl("txtPrimaryLanguage")
tmpName = txtName.Text
tmpRosterNumber = txtRosterNumber.Text
tmpPrimaryLanguage = txtPrimaryLanguage.Text
Dim ClassProfile As New ClassProfile1112.Caseload
ClassProfile.UpdateCaseloadProfile1213(Intid, tmpName, tmpRosterNumber, tmpPrimaryLanguage)
dgCaseload.EditItemIndex = -1
BindDataGridCaseload()
SetFocus(dgCaseload)
End Sub
Private Sub dgCaseload_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgCaseload.CancelCommand
dgCaseload.EditItemIndex = -1
BindDataGridCaseload()
SetFocus(dgCaseload)
End Sub
Private Sub dgCaseload_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgCaseload.DeleteCommand
Dim IntID As Integer
IntID = dgCaseload.DataKeys(e.Item.ItemIndex)
Dim ClassProfile As New ClassProfile1112.Caseload
ClassProfile.DeleteCaseloadProfile(IntID)
BindDataGridCaseload()
SetFocus(dgCaseload)
End Sub
Private Sub dgCaseload_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgCaseload.EditCommand
dgCaseload.EditItemIndex = e.Item.ItemIndex
BindDataGridCaseload()
SetFocus(dgCaseload)
End Sub
inkaln
Member
533 Points
237 Posts
datagrid's UpdateCommand not being called....
Dec 11, 2012 09:49 PM|LINK
Hi,
I don't know why this is happening. I have a radiobuttonList on my page and a datagrid. Based on the selection of Class number (1 or 2), the datagrid is populated, which works fine. Initially, the class number 1 populates and I can edit/update/delete without any problems on this. When I switch to Class # 2, the items appear correctly; however, when I tried to Edit and Update an item, it does not call the Update command. Any ideas as to what's causing this when I switch to Class # 2?
yuvakom
Member
28 Points
47 Posts
Re: datagrid's UpdateCommand not being called....
Dec 12, 2012 10:36 AM|LINK
If u r using update panel means, remove that and check it
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: datagrid's UpdateCommand not being called....
Dec 12, 2012 12:16 PM|LINK
What codes have you written?
inkaln
Member
533 Points
237 Posts
Re: datagrid's UpdateCommand not being called....
Dec 12, 2012 08:43 PM|LINK
I'm not using any panels....it's working fine when the page loads initially when the default value in radiobutton is "1", which is Class 1. When I change to selected value 2, the textboxes come up when clicking on edit, however, when clicking on "Update", it does not actually go through the Update procedure. The Cancel and Delete command also work fine, just the Update doesn't.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: datagrid's UpdateCommand not being called....
Dec 13, 2012 12:02 AM|LINK
Can you show us your full codes of aspx and cs ones?
inkaln
Member
533 Points
237 Posts
Re: datagrid's UpdateCommand not being called....
Dec 13, 2012 02:48 PM|LINK
<asp:DataGrid ID="dgCaseload" runat="Server" AutoGenerateColumns="False" CellPadding="4"
HeaderStyle-BackColor="Black" HeaderStyle-ForeColor="White" HeaderStyle-HorizontalAlign="Center"
HeaderStyle-Font-Bold="True" DataKeyField="ID" ForeColor="#333333" GridLines="None">
<Columns>
<asp:TemplateColumn HeaderText="ID" HeaderStyle-HorizontalAlign="Left" Visible="false">
<ItemTemplate>
<asp:Label ID="lblid" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ID") %>'
Visible="False"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblidedit" runat="server" Visible="False"></asp:Label>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Name" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label ID="lblName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>'>></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtName" runat="server" MaxLength="3"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Roster #" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:Label ID="lblRosterNumber" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "RosterNumber") %>'>></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtRosterNumber" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="vldNumber" ValidationExpression="(^([0-9]*|\d*\d{1}?\d*)$)"
runat="server" ControlToValidate="txtRosterNumber" ErrorMessage="Roster Number must be an integer"></asp:RegularExpressionValidator>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Student's Primary Language" HeaderStyle-HorizontalAlign="left">
<ItemTemplate>
<asp:Label ID="lblPrimaryLanguage" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "PrimaryLanguage") %>'>></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtPrimaryLanguage" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="lnkEdit" runat="server" Text="Edit" CommandName="edit" Enabled='<%# HasAccess() %>'
CausesValidation="false">
</asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="lnkSave" runat="server" CommandName="update" Text="update" CausesValidation="false">
</asp:LinkButton>
<asp:LinkButton CommandName="Cancel" ID="lnkcancel" runat="server" Text="cancel"
CausesValidation="false">
</asp:LinkButton>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="lnkDel" runat="server" CommandName="Delete" Text="Delete" Enabled='<%# HasAccess() %>'
CausesValidation="false">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditItemStyle BackColor="#999999" />
<SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" PageButtonCount="5" />
<AlternatingItemStyle BackColor="White" ForeColor="#284775" />
<ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />
<HeaderStyle BackColor="#99EEBC" Font-Bold="True" ForeColor="Black" HorizontalAlign="Center" />
</asp:DataGrid>
Below is what I have in the code behind....
In the pageload, I have the following code related to the datagrid:
If Not Page.IsPostBack Then
BindDataGridCaseload()
End If
Sub BindDataGridCaseload()
If Not Request.Params("ClassNumber") = "" Then
ClassNumber = CType(Request.Params("ClassNumber"), Integer)
Else
ClassNumber = 1
End If
connection.Open()
Dim ds As Data.DataSet = New Data.DataSet()
Dim objAdapter As New SqlDataAdapter("SELECT * FROM CaseloadProfile WHERE PAID= " & PAID & "AND " & "Dropped=" & 0 & "AND " & "ClassNumber=" & ClassNumber & "", connection)
objAdapter.Fill(ds, "CaseloadProfile")
Me.dgCaseload.DataSource = ds.Tables("CaseloadProfile").DefaultView
dgCaseload.DataBind()
connection.Close()
SetFocus(dgCaseload)
End Sub
Private Sub dgCaseload_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgCaseload.UpdateCommand Dim Intid As Integer Dim txtName As TextBox Dim txtPrimaryLanguage As TextBox Dim tmpName, tmpRosterNumber, tmpPrimaryLanguage As String Intid = dgCaseload.DataKeys(e.Item.ItemIndex) txtName = e.Item.FindControl("txtName") txtRosterNumber = e.Item.FindControl("txtRosterNumber") txtPrimaryLanguage = e.Item.FindControl("txtPrimaryLanguage") tmpName = txtName.Text tmpRosterNumber = txtRosterNumber.Text tmpPrimaryLanguage = txtPrimaryLanguage.Text Dim ClassProfile As New ClassProfile1112.Caseload ClassProfile.UpdateCaseloadProfile1213(Intid, tmpName, tmpRosterNumber, tmpPrimaryLanguage) dgCaseload.EditItemIndex = -1 BindDataGridCaseload() SetFocus(dgCaseload) End SubPrivate Sub dgCaseload_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgCaseload.CancelCommand dgCaseload.EditItemIndex = -1 BindDataGridCaseload() SetFocus(dgCaseload) End Sub Private Sub dgCaseload_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgCaseload.DeleteCommand Dim IntID As Integer IntID = dgCaseload.DataKeys(e.Item.ItemIndex) Dim ClassProfile As New ClassProfile1112.Caseload ClassProfile.DeleteCaseloadProfile(IntID) BindDataGridCaseload() SetFocus(dgCaseload) End SubPrivate Sub dgCaseload_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgCaseload.EditCommand dgCaseload.EditItemIndex = e.Item.ItemIndex BindDataGridCaseload() SetFocus(dgCaseload) End SubDecker Dong ...
All-Star
118619 Points
18779 Posts
Re: datagrid's UpdateCommand not being called....
Dec 14, 2012 12:16 AM|LINK
Hello,
I come here to check whether the problem is solved or not. Because I see the state of your issue is "Solved".