Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# GridView中带有链接按钮的行命令_C#_Asp.net_Gridview - Fatal编程技术网

C# GridView中带有链接按钮的行命令

C# GridView中带有链接按钮的行命令,c#,asp.net,gridview,C#,Asp.net,Gridview,我有两种观点。GridView1在一列中包含2个链接按钮。在GridView1中选择链接按钮时,链接按钮的详细信息应显示在GridView2中 GridView2包含一个带有单选按钮的列。我需要从数据库中动态填充单选按钮 如何使用GridView1_row命令填写GridView2的单选按钮列表?或者我可以从GridView2的RowDataBound事件中获取它吗 代码隐藏: protected void GridView1_RowCommand(Object sender, GridView

我有两种观点。GridView1在一列中包含2个链接按钮。在GridView1中选择链接按钮时,链接按钮的详细信息应显示在GridView2中

GridView2包含一个带有单选按钮的列。我需要从数据库中动态填充单选按钮

如何使用GridView1_row命令填写GridView2的单选按钮列表?或者我可以从GridView2的RowDataBound事件中获取它吗

代码隐藏:

protected void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e)
{            
    if (e.CommandName == "Yes")
    {           
        GridViewRow gvRow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
        int RowIndex = gvRow.RowIndex;            
        Int32 iAppID = Convert.ToInt32(GridView1.DataKeys[gvRow.RowIndex].Value.ToString());               

        dset = userApps.UserSelectedApp(iUserID, iAppID);
        if (dset.Tables[0].Rows.Count > 0)
        {
            GridViewRow gRow = GridView2.Rows[RowIndex];//I need to create object to this Gridview2, and fill the radiobutton list with some values
            RadioButtonList rdbtnSubPlans = (RadioButtonList)e.gRow.Cells[2].FindControl("rdbSubPlans");

            ds = userApps.UpgradePlans(iUserID, iAppID);
            if (ds != null)
            {
                rdbtnSubPlans.DataSource = ds;
                rdbtnSubPlans.DataValueField = "PlanID";
                rdbtnSubPlans.DataTextField = "Plans";
                rdbtnSubPlans.DataBind();
            }
        }
    }
    if (e.CommandName == "No")
    {}
     dtset = user.UserSelectedAppication(iUserID, iAppID);    
     GridView2.DataSource = dtset;
     GridView2.DataBind();
     MultiView1.SetActiveView(viewRenewOrUpdate);                
    }
}  
GridView的ASPX代码

<asp:GridView ID="GridView1" runat="server" DataKeyNames="ApplicationID" 
    OnRowDataBound="GridView1_RowDataBound" OnRowCommand="GridView1_RowCommand" 
    OnSorting="GridView1_Sorting" OnDataBound="GridView1_DataBound"
    OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
    <Columns>
        <asp:TemplateField HeaderText="S.No" ItemStyle-HorizontalAlign="center" HeaderStyle-HorizontalAlign="center">
            <ItemTemplate>
                <asp:Label ID="l1" runat="server" Text="1"></asp:Label>
            </ItemTemplate>
            <HeaderStyle Width="10%" />
        </asp:TemplateField>
        < Some Bound Fields>                                                   
        <asp:TemplateField HeaderText="Action">
            <ItemTemplate>
                <asp:LinkButton ID="lnkYes" runat="server" Text="Yes" 
                    CssClass="lnkbtn" Visible="false" commandname="Yes" Width="100px" >
                </asp:LinkButton>
                &nbsp;
                <asp:LinkButton ID="lnkNo" runat="server" CssClass="lnkbtn" Text="No" 
                    Visible="false" commandname="No" ToolTip="No and Yes current plan" Width="100px" >
                </asp:LinkButton>
            </ItemTemplate>                                                        
        </asp:TemplateField>
    </Columns>                                               
</asp:GridView>

<asp:GridView ID="GridView2" runat="server" DataKeyNames="ApplicationID"
    OnRowDataBound="GridView2_RowDataBound">
    <Columns>
        <asp:BoundField DataField="ApplicationName" HeaderText="Application name">
            <HeaderStyle Width="30%" />
            <ItemStyle CssClass="col" />
        </asp:BoundField>
        <asp:TemplateField HeaderText="Plans">
            <ItemTemplate>
                <asp:RadioButtonList ID="rdbSubPlans" runat="server" AutoPostBack="true" 
                    OnSelectedIndexChanged="rdbSubPlan_OnSelectedIndexChanged" Enabled="false">
                </asp:RadioButtonList>
            </ItemTemplate>
        <ItemStyle CssClass="col" />
    </Columns>
</asp:GridView>

<一些绑定字段>

首先填充Gridview2,然后执行以下更正:

GridViewRow gRow = GridView2.Rows[0]
RadioButtonList rdbtnPlans = (RadioButtonList)gRow.FindControl("rdbPlans");

那么问题出在哪里呢?我需要在GridView2中获得单选按钮列表。我收到一个错误,例如System.Web.UI.WebControl.GridViewCommandEventArgs'不包含“gRow”的定义,并且找不到接受“System.Web.UI.WebControl.GridViewCommandEventArgs”类型的第一个参数的扩展方法“gRow”(您是否缺少using指令或程序集引用?RowCommand事件是GridView1的事件,基于GridView1的选定链接按钮,我需要用单选按钮列表填充GridView2的一列。能否显示您的aspx页面Gridviews htmlwhy是if(e.CommandName==“Yes”)主体中的if(e.CommandName==“No”)?np:)如果你能把它标记为答案,那就太好了。谢谢。快乐编码:)