tags:

views:

968

answers:

2

Hi,

I am using radgrid with rowcontextmenu. when i right click on a radgrid row and select edit option it will open a popup window. What i need is when i rightclick on a radgrid row, i just want to get the values of 3 columns for that particular selected row. For example, when i right click on a selected radgrid row i want to get customer name, headend name, site name values of that selected row.

Here is my code....

<MasterTableView GridLines="None" DataKeyNames="orderId" CommandItemDisplay="Top"
                        EditMode="EditForms">
                        <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" ReadOnly="true"
                                Visible="false">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="orderId" HeaderText="orderId" Visible="false"
                                ReadOnly="true" DataField="orderId">
                            </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:GridTemplateColumn UniqueName="Site Name" HeaderText="Site Name" DataField="SiteName"
                                ReadOnly="true">
                                <ItemTemplate>
                                    <asp:LinkButton ID="lnkSiteName" runat="server" Text='<%# Eval( "Site Name" ) %>'
                                        ForeColor="Blue" CommandName="sitename"></asp:LinkButton>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn UniqueName="Task Status" HeaderText="Task Status" DataField="Task Status"
                                ReadOnly="true">
                            </telerik:GridBoundColumn>
                            <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="EditCommandColumn" Display="false">
                            </telerik:GridEditCommandColumn>
                        </Columns>

    protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)
{
    int radGridClickedRowIndex;

    radGridClickedRowIndex = Convert.ToInt32(Request.Form["radGridClickedRowIndex"]);

    switch (e.Item.Text)
    {
        case "Edit Task":
            string OrdID = rg200.MasterTableView.DataKeyValues[radGridClickedRowIndex]["orderId"].ToString();
            lblOrdHeadName.Text = rg200.MasterTableView.NamingContainer.FindControl("Headend Name").ToString();

            Session["orderId"] = OrdID;
            ifrmPopups.Style.Add("height", "409px");
            StringBuilder Script = new StringBuilder();
            Script.Append("document.getElementById('ctl00_PagePlaceholder_WinEditForm_C_ifrmPopups');openpopups()");
            RadAjaxManager1.ResponseScripts.Add(Script.ToString());
            rg200.Rebind();
            break;
    }
}

if you see the above code, I am able to get the orderId value for that selected column. But when I am trying to get Headend Name value I am getting error. How to get headend Name value for selected row.

Thanks In Advance

A: 

Try out this code to get the Headend Name value from the right-clicked row: lblOrdHeadName.Text = (rg200.MasterTableView.FindItemByKeyValue("orderId") as GridDataItem)["Headend Name"].Text;

Dick

Dick Lampard
No Problem I found silution....GridDataItem item = (GridDataItem)rg200.MasterTableView.Items[radGridClickedRowIndex]; lblOrdHeadName.Text = item["HeadendName"].Text;
A: 

No Problem I found solution

GridDataItem item = (GridDataItem)rg200.MasterTableView.Items[radGridClickedRowIndex];

lblOrdHeadName.Text = item["HeadendName"].Text;