Retriving data from the Grid for updating

2 posts, 0 answers
  1. daouddajani
    daouddajani avatar
    6 posts
    Member since:
    Apr 2007

    Posted 07 Jun 2008 Link to this post

    i can cast the dropdown in the grid to a dropdown it only casts to literal with the old value not the update one.

    <

    telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticInserts="True" AllowPaging="True" DataSourceID="linqDatasource1" GridLines="None" PageSize="30" Skin="Mac">
    <MasterTableView AutoGenerateColumns="False" DataSourceID="LinqDataSource1">

    <CommandItemTemplate>
    <asp:LinkButton ID="btnUpdate" runat="server">Update</asp:LinkButton>
    </CommandItemTemplate>
    <RowIndicatorColumn Visible="False">
    <HeaderStyle Width="20px" />
    </RowIndicatorColumn>
    <ExpandCollapseColumn Resizable="False" Visible="False">
    <HeaderStyle Width="20px" />
    </ExpandCollapseColumn>
    <Columns>
    <telerik:GridEditCommandColumn ButtonType="ImageButton"></telerik:GridEditCommandColumn>

    <telerik:GridBoundColumn DataField="ticketID" EditFormColumnIndex="1" HeaderText=" " ReadOnly="true" SortExpression="ticketID" UniqueName="ticketID"></telerik:GridBoundColumn>

    <telerik:GridDropDownColumn DataField="phonenumber" DataSourceID="ldphones" HeaderText=" " ItemStyle-HorizontalAlign="Right" ListTextField="phonenumber" ListValueField="phonenumber" ReadOnly="false" SortExpression="phonenumber" UniqueName="phonenumber" Visible="true">
    <ItemStyle HorizontalAlign="Right" /></telerik:GridDropDownColumn>

    <telerik:GridDropDownColumn DataField="EmployeeID" DataSourceID="ldemployees" HeaderText="" ItemStyle-HorizontalAlign="Right" ListTextField="EmployeefName" ListValueField="EmployeeID" ReadOnly="false" SortExpression="EmployeeID" UniqueName="EmployeeID" Visible="false">
    <ItemStyle HorizontalAlign="Right" /></telerik:GridDropDownColumn>

    <telerik:GridDropDownColumn DataField="deviceserial" DataSourceID="ldSerials" HeaderText=" " ItemStyle-HorizontalAlign="Right" ListTextField="deviceserial" ListValueField="deviceserial" ReadOnly="false" SortExpression="deviceserial" UniqueName="deviceserial" Visible="true"><ItemStyle HorizontalAlign="Right" /></telerik:GridDropDownColumn>

    <telerik:GridBoundColumn DataField="ProblemDescription" EditFormColumnIndex="1" HeaderText="" ReadOnly="false" SortExpression="ProblemDescription" UniqueName="ProblemDescription">
    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="ProblemSolution" EditFormColumnIndex="1" HeaderText=" " ReadOnly="false" SortExpression="ProblemSolution" UniqueName="ProblemSolution" Visible="false"></telerik:GridBoundColumn>

    '--------- this it the one that returns the error

    <telerik:GridDropDownColumn DataField="TicketStatus" DataSourceID="ldphonestatus" HeaderText=" " ItemStyle-HorizontalAlign="Right" ListTextField="Phonestatus" ListValueField="Phonestatusid" ReadOnly="false" SortExpression="TicketStatus" UniqueName="TicketStatus" Visible="false">
    <ItemStyle HorizontalAlign="Right" />

    </telerik:GridDropDownColumn>
    '------------------------------------------------

    <telerik:GridCheckBoxColumn DataField="Onemployee" HeaderText=" " Visible="false" UniqueName="OnEmployee">
    </telerik:GridCheckBoxColumn>

    <
    telerik:GridBoundColumn ReadOnly="false" Visible="false" DataField="TicketDate" UniqueName="ticketDate" SortExpression="ticketDate" HeaderText=""></telerik:GridBoundColumn>

    <
    telerik:GridBoundColumn DataField="returnDate" HeaderText=" " ReadOnly="false" SortExpression="returnDate" UniqueName="returnDate" EditFormColumnIndex="1" Visible="false">
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn DataField="FixCost" EditFormColumnIndex="1" HeaderText=" " ReadOnly="false" SortExpression="FixCost" UniqueName="FixCost" Visible="false"></telerik:GridBoundColumn></Columns>

    <EditFormSettings CaptionFormatString=" " ColumnNumber="2"><PopUpSettings ScrollBars="None" /><EditColumn ButtonType="ImageButton" CancelText="" UpdateText=""></EditColumn></EditFormSettings></MasterTableView><PagerStyle Mode="NumericPages" /></telerik:RadGrid>



    this is my code behind

    Protected

    Sub RadGrid1_UpdateCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand

    Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem)

    Dim TickeID = DirectCast(item("ticketID").Controls(0), TextBox)

    Dim TicketDate = DirectCast(item("ticketDate").Controls(0), TextBox)

    Dim ProblemDescription = DirectCast(item("ProblemDescription").Controls(0), TextBox)

    Dim Problemsolution = DirectCast(item("ProblemSolution").Controls(0), TextBox)

    Dim fixcost = DirectCast(item("FixCost").Controls(0), TextBox)

    Dim returnDate = DirectCast(item("returnDate").Controls(0), TextBox)

    Dim onEmployee = DirectCast(item("OnEmployee").Controls(0), CheckBox)

    Dim employeeID = DirectCast(item("EmployeeID").Controls(0), RadComboBox)

    Dim phonenumber = DirectCast(item("phonenumber").Controls(0), RadComboBox)

    Dim DeviceSerial = DirectCast(item("deviceserial").Controls(0), RadComboBox)

    '--- doesnot work returns typecast error
    Dim
    ticketstatus = DirectCast(item("ticketStatus").Controls(0), RadComboBox)

    ' ---works but return old values
    Dim ticketstatus = DirectCast(item("ticketStatus").Controls(0), literal)



    Dim
    ds As New mobilesdcDataContext

    ds.updateMentainance(TickeID.Text, ticketstatus.Text, Problemsolution.Text, fixcost.Text, onEmployee.Checked,

    Date.Now)

    ds.SubmitChanges()

    End Sub

  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 10 Jun 2008 Link to this post

    Hello daouddajani,

    You can use the ExtractValuesFromItem method. Additionally, you can try setting the control type for the dropdown column to DropDownControlType="DropDownList", since the default type is a combobox.

    Greetings,
    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top