Hi,
I'm using a radgrid to load 3 rows of data on the page initially. The grid is bound to the client and it all works fine. The first column is the ID column which I need to access in codebehind to get the value of the column in order to save the newly added data. I've tried everything to access the data in the ID column with no success. There is data in the ID because I can see it in the grid and even when I open firebug. It is so weird. Here's the code and a screen shot which shoes the data in the ID column is present.
I'm using a radgrid to load 3 rows of data on the page initially. The grid is bound to the client and it all works fine. The first column is the ID column which I need to access in codebehind to get the value of the column in order to save the newly added data. I've tried everything to access the data in the ID column with no success. There is data in the ID because I can see it in the grid and even when I open firebug. It is so weird. Here's the code and a screen shot which shoes the data in the ID column is present.
<telerik:RadGrid ID="grdInvoiceItems" runat="server" Width="934px" AutoGenerateColumns="false" EnableViewState="true" AllowMultiRowEdit="false" onitemcreated="grdInvoiceItems_ItemCreated" Skin="Silk" ShowHeader="false" style="border:0" BorderColor="#CCCCCC"> <ClientSettings> <ClientEvents OnRowMouseOver="showContent" OnRowMouseOut="hideContent" OnCommand="gridCommand" OnRowDataBound="RowDataBound" /> </ClientSettings> <MasterTableView ClientDataKeyNames="Id,Description" DataKeyNames="Id" CommandItemDisplay="None" > <ItemStyle Height="50px" /> <AlternatingItemStyle Height="50px" /> <Columns> <telerik:GridBoundColumn DataField="Id" HeaderText="Id" UniqueName="Id"></telerik:GridBoundColumn> <telerik:GridTemplateColumn DataField="Item" UniqueName="Item"> <ItemStyle /> <ItemTemplate> <telerik:RadComboBox ID="ddlItems" runat="server" AutoPostBack="false" DataSourceID="objItems" DataTextField="Items" DataValueField="Items" Skin="Default" OnClientDropDownOpening="DropDownOpening" OnClientSelectedIndexChanged="ItemValueChanged" EnableViewState="true" AllowCustomText="False" Width="160px" Height="150px" ondatabound="ddlItems_DataBound" EmptyMessage="Select an item" FocusedStyle-BackColor="#fff6dc" > </telerik:RadComboBox> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn DataField="Description" HeaderText="Description" UniqueName="Description"> <ItemStyle /> <ItemTemplate> <telerik:RadTextBox ID="txtDescription" Width="320px" Height="30px" CssClass="ItemsGridTextBoxAlighLeft" runat="server" FocusedStyle-BackColor="#fff6dc"></telerik:RadTextBox> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn DataField="Price" HeaderText="Price" UniqueName="Price"> <ItemStyle Width="100px" /> <ItemTemplate> <telerik:RadNumericTextBox ID="txtPrice" Width="100px" Height="30px" CssClass="ItemsGridPriceTextBox" runat="server" FocusedStyle-BackColor="#fff6dc" > <ClientEvents OnValueChanged="PriceChanged" OnFocus="OnPriceFocusGetColumnValues" /> </telerik:RadNumericTextBox> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn DataField="Qty" HeaderText="Qty" UniqueName="Qty"> <ItemStyle Width="50px" /> <ItemTemplate> <telerik:RadNumericTextBox ID="txtQty" Width="50px" Height="30px" CssClass="ItemsGridQtyTextBox" runat="server" FocusedStyle-BackColor="#fff6dc" > <NumberFormat DecimalDigits="0" /> <ClientEvents OnValueChanged="QtyChanged" OnFocus="OnQtyFocusGetColumnValues" /> </telerik:RadNumericTextBox> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn DataField="Discount" HeaderText="Discount" UniqueName="Discount"> <ItemStyle Width="85px" CssClass="ColumnDiscount" /> <ItemTemplate> <telerik:RadNumericTextBox ID="txtDiscount" Width="85px" Height="30px" CssClass="ItemsGridDiscountTextBox" runat="server" FocusedStyle-BackColor="#fff6dc"> <ClientEvents OnValueChanged="DiscountChanged" OnFocus="OnDiscountFocusGetColumnValues" /> </telerik:RadNumericTextBox> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn DataField="Amount" HeaderText="Amount" UniqueName="Amount" > <ItemStyle Width="105px" /> <HeaderStyle Width="105px" HorizontalAlign="Center" /> <ItemTemplate > <telerik:RadNumericTextBox ID="lblAmount" runat="server" CssClass="ItemsGridAmount" Width="105px" Height="30px" > <ClientEvents OnValueChanged="AmountChanged" /> </telerik:RadNumericTextBox> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn> <HeaderStyle Width="0px" /> <ItemStyle BorderStyle="None" CssClass="ImgColumn" /> <ItemTemplate> <div id="deleteRow" class="myWrap1" style="visibility:hidden" onclick="DeleteRow();"> <asp:HyperLink ID="DeleteLink" runat="server"> <asp:Image ID="DeleteCategory" runat="server" ImageUrl="~/Images/icons/test/Delete.png" AlternateText="Delete Row" /> </asp:HyperLink> </div> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="InvoiceId" HeaderText="InvoiceId" UniqueName="InvoiceId" ItemStyle-CssClass="InvoiceIdColumn"> </telerik:GridBoundColumn>foreach (GridDataItem item in grdInvoiceItems.Items) { //object id = (object)item.OwnerTableView.DataKeyValues[item.ItemIndex]["Id"]; object value = item["Id"].Text; id = (item["Id"].FindControl("lblId") as RadTextBox).Text; string lineItem = (item["Item"].FindControl("ddlItems") as RadComboBox).Text; string description = (item["Description"].FindControl("txtDescription") as RadTextBox).Text; double? price = (item["Price"].FindControl("txtPrice") as RadNumericTextBox).Value; double? qty = (item["Qty"].FindControl("txtQty") as RadNumericTextBox).Value; double? discount = (item["Discount"].FindControl("txtDiscount") as RadNumericTextBox).Value; //double tax = double.Parse(lblTaxes.Text); //Label amount1 = (item["Amount"].FindControl("lblAmount") as Label); //string amount = item["Amount"].Text; //Label amount1 = (item.FindControl("lblAmount") as Label); double? amounnt = (item["Amount"].FindControl("lblAmount") as RadNumericTextBox).Value; if (!string.IsNullOrEmpty(lineItem)) { Invoice.UpdateInvoiceItems(Convert.ToInt32(id), lineItem, description, Convert.ToDouble(price), Convert.ToInt32(qty), Convert.ToDouble(discount), 0, Convert.ToDouble(amounnt)); } }