gpt4 book ai didi

telerik - 如何在 radgrid 中查找选定行的列值

转载 作者:行者123 更新时间:2023-12-01 09:09:00 31 4
gpt4 key购买 nike

我将 RadGridrowcontextmenu 一起使用。当我右键单击 RadGrid 行并选择“编辑选项”时,它将打开一个弹出窗口。

我需要的是,当我右键单击 Radgrid 行时,我只想获取该特定选定行的 3 列的值。例如,当我右键单击选定的 Radgrid 行时,我想获取该选定行的 Customer nameHeadend nameSite name 值.

这是我的代码:

<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>
</Mastertableview>
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;
}
}

如果您看到上面的代码,我可以获得该选定列的 orderId 值。但是,当我尝试获取 Headend Name 值时,我遇到了错误。如何获取所选行的 Headend Name 值?

最佳答案

试试下面的。它对我有用。

GridDataItem item =(GridDataItem)rg200.MasterTableView.Items[rg200.SelectedItems[0].ItemIndex];

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

关于telerik - 如何在 radgrid 中查找选定行的列值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3364714/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com