0

我正在尝试从位于表单视图控件内的列表框中的数据库中获取数据,我已将来自 gridview 的选定值作为表单视图控件和列表框的参数传递。表单视图控件正常工作,但无法获取列表框中的数据。

我用过的查询

   SELECT mst_Tag.tagId, mst_Tag.Tag_Name FROM mst_Tag INNER JOIN Post2Tag ON mst_Tag.tagId = Post2Tag.Tag_Id WHERE (Post2Tag.Post_Id = @Post_Id)

@Post_Id= gridview1.SelectedValue
4

2 回答 2

3

protected void frmview_ItemInserting(object snd, FormViewInsertEventArgs 格式) {

        RadListBox lst = (RadListBox)frmview.FindControl("RadLstUnselectedIns");
        DataSet dsData = objMenuMBAL.getAction(0);
        DataTable dtDataunsel = dsData.Tables[0];
        if (dtDataunsel.Rows.Count > 0)
        {
            lst.DataSource = dtDataunsel;
            lst.DataTextField = "Action";
            lst.DataValueField = "Action";
            lst.DataBind();
        }
        RadListBox lstselected = (RadListBox)frmview.FindControl("RadLstselectedIns");
    }
于 2013-04-02T08:49:09.860 回答
1

这是 SP :

ALTER PROCEDURE [dbo].[MenuAction__Sel_UnSel]
        -- Add the parameters for the stored procedure here
    (
        @MenuId INT
    )
    AS
    BEGIN
        -- SET NOCOUNT ON added to prevent extra result sets from
        -- interfering with SELECT statements.
        SET NOCOUNT ON;

        -- Insert statements for procedure here

        ---- Unselected Record

        Select  a.Action,'DB' AS DML_TYP
          from dbo.MenuAction_m a
         Where NOT EXISTS (SELECT 1 FROM dbo.Menu_d AS b WHERE B.Action=A.Action AND B.MenuId=@MenuId);

         ---- Selected Record

       Select  c.MenuId,a.Action,'DB' AS DML_TYP
          from dbo.MenuAction_m a,Menu_d as c 
         WHERE a.Action=c.Action and  EXISTS (SELECT 1 FROM dbo.Menu_d AS b WHERE B.Action=A.Action AND b.MenuId=@MenuId and c.Action=b.Action and c.MenuId=b.MenuId) ;
    END

这是设计页面:

<tr class="odd">
                                        <td class="column1">
                                            <b>UnSelected Items</b>
                                        </td>
                                        <td>
                                            <b>Selected Items</b>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="column1">
                                            <telerik:RadListBox ID="RadLstUnselectedIns" runat="server" AllowTransfer="true"
                                                AutoPostBackOnTransfer="true" Height="120px" SelectionMode="Multiple" TransferToID="RadLstselectedIns">
                                                <ButtonSettings TransferButtons="All" />
                                            </telerik:RadListBox>
                                            <telerik:RadToolTip ID="radToolTipRadLstUnselected" runat="server" RelativeTo="Element"
                                                Height="40px" Text="This Actions are not Selected!" TargetControlID="RadLstUnselectedIns"
                                                Position="MiddleRight" EnableAriaSupport="true">
                                            </telerik:RadToolTip>
                                        </td>
                                        <td>
                                            <telerik:RadListBox ID="RadLstselectedIns" runat="server" Height="120px">
                                            </telerik:RadListBox>
                                            <telerik:RadToolTip ID="radToolTipRadLstselectedIns" runat="server" RelativeTo="Element"
                                                Height="40px" Text="This Actions are  Selected!" TargetControlID="RadLstselectedIns"
                                                Position="MiddleRight" EnableAriaSupport="true">
                                            </telerik:RadToolTip>
                                        </td>
                                    </tr>

这是背后的代码:

   protected void frmview_ItemInserting(object sender, FormViewInsertEventArgs e)
        {

            RadListBox lstUnselected = (RadListBox)frmview.FindControl("RadLstUnselectedIns");
            DataSet dsData = objMenuMBAL.getAction(0);
            DataTable dtDataunsel = dsData.Tables[0];
            if (dtDataunsel.Rows.Count > 0)
            {
                lstUnselected.DataSource = dtDataunsel;
                lstUnselected.DataTextField = "Action";
                lstUnselected.DataValueField = "Action";
                lstUnselected.DataBind();
            }
            RadListBox lstselected = (RadListBox)frmview.FindControl("RadLstselectedIns");
        }
于 2013-04-02T06:08:46.153 回答