We help IT Professionals succeed at work.

Edit and updating columns in radgrid

prasadpbr
prasadpbr used Ask the Experts™
on
Hi,

We recently bought Asp.net Ajax control. We are migrating to asp.net grid ti radgrid. In my grid I ma editing and updating my rows. When I am trying to implement that in radgrid I am getting too many errors. Can any one help me how to do that? In which command i need to write the code???

What i want is once i edit the radgrid, i just want to catch the text in the textbox after i edited it. See the modified question above.

the above functionality i did in gridview as follows. But i dont know how to do it radgrid


protected void gvCktMap_RowUpdating(object sender, GridViewUpdateEventArgs e) 
{ 
    try 
    { 
        if (Session["TaskID"] != null) 
        { 
            string strTaskID = (string)Session["TaskID"]; 
            if (strTaskID != string.Empty) 
            {                     
                bool bolStatus = false; 
                clsTaskUpdates_BL objBL = new clsTaskUpdates_BL(); 
                Label lblOrdID = (Label)gvCktMap.Rows[e.RowIndex].FindControl("lblorderId"); 
                string strOrdId = lblOrdID.Text; 
                DataSet dsStatus = objBL.getTaskStatus_BL(lblOrdID.Text.Trim(), strTaskID.Trim()); 
                if (dsStatus.Tables[0].Rows.Count > 0) 
                { 
                    if (dsStatus.Tables[0].Rows[0][0].ToString() == "3" || dsStatus.Tables[0].Rows[0][0].ToString() == "4") 
                        bolStatus = true; 
                } 
                if (!bolStatus) 
                { 
                    Session["SearchRes"] = null; 
                    if (strTaskID == "200") 
                    { 
                        TextBox txtClarifyID = (TextBox)gvCktMap.Rows[e.RowIndex].FindControl("txtClarifyAccountNbr"); 
                        TextBox txtSiteID = (TextBox)gvCktMap.Rows[e.RowIndex].FindControl("txtSiteID"); 
                        TextBox txtQuoteID = (TextBox)gvCktMap.Rows[e.RowIndex].FindControl("txtQuoteID"); 
                        CheckBox chkEDP = (CheckBox)gvCktMap.Rows[e.RowIndex].FindControl("chkEditEDPCreated?"); 
                        objBL.setTask200_Bl(lblOrdID.Text, txtClarifyID.Text, txtSiteID.Text, txtQuoteID.Text, chkEDP.Checked); 
                        gvCktMap.EditIndex = -1; 
                        bingGrid(); 
                    } 
                    else if (strTaskID == "206") 
                    { 
                        TextBox txtConfigGenDate = (TextBox)gvCktMap.Rows[e.RowIndex].FindControl("txtConfigGenDate"); 
                        objBL.setTask206_Bl(lblOrdID.Text, txtConfigGenDate.Text); 
                        gvCktMap.EditIndex = -1; 
                        bingGrid(); 
                    } 
                    else if (strTaskID == "207") 
                    { 
                        TextBox txtCPEShipDate = (TextBox)gvCktMap.Rows[e.RowIndex].FindControl("txtCPEShipDate"); 
                        TextBox txtPackageSlip = (TextBox)gvCktMap.Rows[e.RowIndex].FindControl("txtPackageSlip"); 
                        objBL.setTask207_Bl(lblOrdID.Text, txtCPEShipDate.Text.Trim(), txtPackageSlip.Text.Trim()); 
                        gvCktMap.EditIndex = -1; 
                        bingGrid(); 
                    } 
                    else if (strTaskID == "208") 
                    { 
                        TextBox txtCORECMNumber = (TextBox)gvCktMap.Rows[e.RowIndex].FindControl("txtCORECMNumber"); 
                        TextBox txtReqSMImpDate = (TextBox)gvCktMap.Rows[e.RowIndex].FindControl("txtReqSMImpDate"); 
                        objBL.setTask208_Bl(lblOrdID.Text, txtReqSMImpDate.Text.Trim(), txtCORECMNumber.Text.Trim()); 
                        gvCktMap.EditIndex = -1; 
                        bingGrid(); 
                    } 
                } 
                else 
                { 
                   // ScriptManager.RegisterClientScriptBlock(this.up, this.GetType(), "updateMsg", "<script>alert('The task has been completed by '" + dsStatus.Tables[0].Rows[0]["tskCompletedBy"].ToString() + " + '. Refresh the task list using F5')</script>", false); 
                    ScriptManager.RegisterClientScriptBlock(this.up,up.GetType(), "updateMsg", "fnStatusMsg()", true); 
                    gvCktMap.EditIndex = -1; 
                    bingGrid(); 
                } 
            } 
        } 

    } 
    catch (Exception ex) 
    { 
    } 
} 

Open in new window




my radgrid aspx file code



<telerik:RadGrid ID="rg200" runat="server" AutoGenerateColumns="False" PageSize="30"
                    Height="550px" OnNeedDataSource="rg200_NeedDataSource" Width="100%" AllowPaging="True"
                    AllowSorting="True" AllowMultiRowSelection="True" EnableHeaderContextMenu="True"
                    GridLines="None" EnableHeaderContextFilterMenu="True" AllowMultiRowEdit="True"
                    AllowFilteringByColumn="True" OnPreRender="rg200_PreRender" OnItemCreated="rg200_ItemCreated"
                    EnableViewState="False" OnUpdateCommand="rg200_UpdateCommand">
                    <HeaderStyle Height="20px" BackColor="#004000" Font-Size="8pt" Font-Bold="True" ForeColor="White"
                        HorizontalAlign="Center" BorderColor="White" BorderWidth="1px" />
                    <ExportSettings IgnorePaging="true" ExportOnlyData="true">
                        <Pdf AllowModify="false" AllowPrinting="true" PageBottomMargin="" PageFooterMargin=""
                            PageHeaderMargin="" PageHeight="11in" PageLeftMargin="" PageRightMargin="" PageTopMargin=""
                            PageWidth="14in" />
                    </ExportSettings>
                    <MasterTableView DataKeyNames="orderId" CommandItemDisplay="Top" EditMode="InPlace">
                        <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true"
                            ShowExportToCsvButton="true" ShowExportToPdfButton="true" ShowAddNewRecordButton="false" />
                        <RowIndicatorColumn Visible="True">
                        </RowIndicatorColumn>
                        <Columns>
                            <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-Width="3%"
                                ItemStyle-Width="3%">
                                <HeaderStyle Width="3%"></HeaderStyle>
                                <ItemStyle Width="3%"></ItemStyle>
                            </telerik:GridClientSelectColumn>
                            <telerik:GridBoundColumn UniqueName="sId" HeaderText="sId" DataField="sId" Visible="false">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="orderId" HeaderText="orderId" DataField="orderId"
                                Visible="false">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="Customer Name" HeaderText="Customer Name" DataField="Customer Name"
                                ReadOnly="true">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="Market Name" HeaderText="Market Name" DataField="Market Name"
                                ReadOnly="true">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="LOB" HeaderText="LOB" DataField="LOB" ReadOnly="true">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="Headend Name" HeaderText="Headend Name" DataField="Headend Name"
                                ReadOnly="true">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="Project Name" HeaderText="Project Name" DataField="Project Name"
                                ReadOnly="true">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="Site Name" HeaderText="Site Name" DataField="Site Name"
                                ReadOnly="true">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="Task Status" HeaderText="Task Status" DataField="Task Status"
                                ReadOnly="true">
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn UniqueName="Clarify Account Nbr" HeaderText="Clarify Account Nbr"
                                DataField="Clarify Account Nbr">
                                <ItemTemplate>
                                    <asp:Label ID="lblClarifyAccountNbr" Text='<%# Eval("Clarify Account Nbr") %>' runat="server"></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtClarifyAccountNbr" Text='<%# Eval("Clarify Account Nbr") %>'
                                        runat="server"></asp:TextBox>
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                            <%-- <telerik:GridBoundColumn UniqueName="Clarify Account Nbr" HeaderText="Clarify Account Nbr"
                                DataField="Clarify Account Nbr">
                            </telerik:GridBoundColumn>--%>
                            <telerik:GridBoundColumn UniqueName="Site ID" HeaderText="Site ID" DataField="Site ID">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="Quote ID" HeaderText="Quote ID" DataField="Quote ID">
                            </telerik:GridBoundColumn>
                            <telerik:GridCheckBoxColumn UniqueName="EDP Created?" HeaderText="EDP Created?" DataField="EDP Created?">
                            </telerik:GridCheckBoxColumn>
                            <telerik:GridEditCommandColumn UniqueName="ECC200">
                            </telerik:GridEditCommandColumn>
                        </Columns>
                        <PagerStyle AlwaysVisible="True"></PagerStyle>
                    </MasterTableView>
</telerik:RadGrid>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
C# ASP.NET Developer
Top Expert 2010
Commented:
What does your code look like for rg200_UpdateCommand? Is it firing?

It should look similar to the code below
GridEditableItem editedItem = e.Item as GridEditableItem;
            Hashtable newValues = new Hashtable();

            if (e.CommandName != RadGrid.UpdateCommandName) return;
            e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
            foreach (GridDataItem gridDataItem in gridLocations.EditItems)
            {

                  int someIntValue = Convert.ToInt32(newValues["ID"]);

Open in new window

Adam MenkesC# ASP.NET Developer
Top Expert 2010

Commented:
Sorry, I pasted from a section of my code and did not notice to change the name from gridLocations to rg200

foreach (GridDataItem gridDataItem in rg200.EditItems)