我尝试更新目录数据库,根据在datagrid表CatalogueList中检查的行,将所有预订的书籍设置为n。
我已经添加了Response.Redirect作为测试,它什么也没做。我相信它没有看到是否已经检查了ItemCheckbox!
Sub updateCat(sender as object, e as system.eventargs)
dim item as datagriditem
For each item in CatalogueList.Items
Dim ItemCheckbox as CheckBox = CType(Item.cells(2).Controls(1), CheckBox)
if ItemCheckbox.Checked = true Then
' was using the redirect as a text
' Response.Redirect("test.aspx")
dim grabid as string = "Select id where cataloguename = '{0}'"
dim mydata as datatable = Database.SelectRows(String.Format(grabid,item.cells(1).Text))
if mydata.Rows.Count > 0 then
dim updatePreorder as string = "Update titles_catalogue set preorder = 'n' where id = '{0}'"
Database.InsertRecord(String.Format(updatePreorder, mydata.rows(0)("id")))
end if
end if
NEXT
End Sub
<asp:DataGrid id="CatalogueList" runat="server"
<Columns>
<asp:BoundColumn HeaderText="ID"
ReadOnly="true"
DataField="id"
Visible="false"/>
<asp:HyperLinkColumn HeaderText="Catalogue Name"
DataNavigateUrlFormatString="view_catalogue.aspx?id={0}"
DataTextFormatString="{0}"
DataNavigateUrlField="id"
DataTextField="name"/>
<asp:TemplateColumn >
<HeaderTemplate>
<asp:CheckBox id="chkHeader" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox id="chkRow" runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
</columns>
</asp:DataGrid>