Hi, I'm having trouble getting the values to update my table from the radgrid. It does not error, just empty for all three newValues.
<telerik:RadGrid ID="rgAntigenLocations" runat="server" GridLines="None" AutoGenerateColumns="False" AllowMultiRowEdit="true" OnItemCommand="ItemCommand" OnItemDataBound="ItemDataBound" OnUpdateCommand="UpdateCommand" OnItemCreated="ItemCreated">
<MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames="ANTIGEN_VIAL_ID"
HorizontalAlign="NotSet" AutoGenerateColumns="False" CommandItemSettings-AddNewRecordText="">
<Columns>
<telerik:GridBoundColumn DataField="ANTIGEN_ID" HeaderText="Antigen Batch #"
UniqueName="ANTIGEN_ID" ColumnEditorID="ANTIGEN_ID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ANTIGEN_CODE" HeaderText="Antigen Code"
UniqueName="ANTIGEN_CODE" ColumnEditorID="ANTIGEN_CODE">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ANTIGEN_VIAL_ID" HeaderText="Antigen Vial #"
UniqueName="ANTIGEN_VIAL_ID" ColumnEditorID="ANTIGEN_VIAL_ID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ANTIGEN_DEWAR" HeaderText="Dewar"
UniqueName="ANTIGEN_DEWAR" ColumnEditorID="ANTIGEN_DEWAR">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ANTIGEN_CANISTER" HeaderText="Canister"
UniqueName="ANTIGEN_CANISTER" ColumnEditorID="ANTIGEN_CANISTER">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ANTIGEN_CANE" HeaderText="Cane"
UniqueName="ANTIGEN_CANE" ColumnEditorID="ANTIGEN_CANE">
</telerik:GridBoundColumn>
</Columns>
<CommandItemTemplate>
<asp:Button runat="server" ID="UpdateAll" Text="Update Storage" CommandName="UpdateAll" />
</CommandItemTemplate>
</MasterTableView>
</telerik:RadGrid>
protected void ItemCommand(object source, GridCommandEventArgs e)
{
string strSQL = "";
SqlCommand SqlCmd = new SqlCommand();
SqlCmd.Connection = DBConn.serologyDBConn();
// Performing bulk update here.
if (e.CommandName == "UpdateAll")
{
SqlCmd.Connection.Open();
foreach (GridDataItem item in rgAntigenLocations.EditItems)
{
Hashtable newValues = new Hashtable();
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, item);
StringBuilder sb = new StringBuilder();
sb.Append("UPDATE TBL_ANTIGEN_VIAL SET ANTIGEN_DEWAR = '");
sb.Append(newValues["ANTIGEN_DEWAR"]);
sb.Append("', ANTIGEN_CANISTER = '");
sb.Append(newValues["ANTIGEN_CANISTER"]);
sb.Append("', ANTIGEN_CANE = '");
sb.Append(newValues["ANTIGEN_CANE"]);
sb.Append("' WHERE ANTIGEN_VIAL_ID = '");
sb.Append(item["ANTIGEN_VIAL_ID"].Text);
sb.Append("'");
strSQL = sb.ToString();
SqlCmd.CommandText = strSQL;
SqlCmd.ExecuteNonQuery();
}
SqlCmd.Connection.Close();
}
rgAntigenLocations.Rebind();
}
<telerik:RadGrid ID="rgAntigenLocations" runat="server" GridLines="None" AutoGenerateColumns="False" AllowMultiRowEdit="true" OnItemCommand="ItemCommand" OnItemDataBound="ItemDataBound" OnUpdateCommand="UpdateCommand" OnItemCreated="ItemCreated">
<MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames="ANTIGEN_VIAL_ID"
HorizontalAlign="NotSet" AutoGenerateColumns="False" CommandItemSettings-AddNewRecordText="">
<Columns>
<telerik:GridBoundColumn DataField="ANTIGEN_ID" HeaderText="Antigen Batch #"
UniqueName="ANTIGEN_ID" ColumnEditorID="ANTIGEN_ID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ANTIGEN_CODE" HeaderText="Antigen Code"
UniqueName="ANTIGEN_CODE" ColumnEditorID="ANTIGEN_CODE">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ANTIGEN_VIAL_ID" HeaderText="Antigen Vial #"
UniqueName="ANTIGEN_VIAL_ID" ColumnEditorID="ANTIGEN_VIAL_ID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ANTIGEN_DEWAR" HeaderText="Dewar"
UniqueName="ANTIGEN_DEWAR" ColumnEditorID="ANTIGEN_DEWAR">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ANTIGEN_CANISTER" HeaderText="Canister"
UniqueName="ANTIGEN_CANISTER" ColumnEditorID="ANTIGEN_CANISTER">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ANTIGEN_CANE" HeaderText="Cane"
UniqueName="ANTIGEN_CANE" ColumnEditorID="ANTIGEN_CANE">
</telerik:GridBoundColumn>
</Columns>
<CommandItemTemplate>
<asp:Button runat="server" ID="UpdateAll" Text="Update Storage" CommandName="UpdateAll" />
</CommandItemTemplate>
</MasterTableView>
</telerik:RadGrid>
protected void ItemCommand(object source, GridCommandEventArgs e)
{
string strSQL = "";
SqlCommand SqlCmd = new SqlCommand();
SqlCmd.Connection = DBConn.serologyDBConn();
// Performing bulk update here.
if (e.CommandName == "UpdateAll")
{
SqlCmd.Connection.Open();
foreach (GridDataItem item in rgAntigenLocations.EditItems)
{
Hashtable newValues = new Hashtable();
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, item);
StringBuilder sb = new StringBuilder();
sb.Append("UPDATE TBL_ANTIGEN_VIAL SET ANTIGEN_DEWAR = '");
sb.Append(newValues["ANTIGEN_DEWAR"]);
sb.Append("', ANTIGEN_CANISTER = '");
sb.Append(newValues["ANTIGEN_CANISTER"]);
sb.Append("', ANTIGEN_CANE = '");
sb.Append(newValues["ANTIGEN_CANE"]);
sb.Append("' WHERE ANTIGEN_VIAL_ID = '");
sb.Append(item["ANTIGEN_VIAL_ID"].Text);
sb.Append("'");
strSQL = sb.ToString();
SqlCmd.CommandText = strSQL;
SqlCmd.ExecuteNonQuery();
}
SqlCmd.Connection.Close();
}
rgAntigenLocations.Rebind();
}