我正在尝试从列表框中的数据库中获取数据,该数据库位于表单视图控件中,我已将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
答案 0 :(得分:3)
protected void frmview_ItemInserting(object snd,FormViewInsertEventArgs format) {
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");
}
答案 1 :(得分: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");
}