我有一个RadGrid,它在RowClick上应该向服务器发送一个特定的值。由于页面的性质,所有事件都在服务器端处理。我的-Radgrid1-在首次访问页面时使用默认的“select”所有sqldatasource,然后,您可以通过单击另一个RadGridAnother来过滤RadGrid1项。它还有一个不同类别的列表。
会发生什么: 1.单击行 2.执行radgrid1_ItemCommand(...,...)。
以下代码在编辑后变为实际:
protected void MenuKampionati_ItemClick(object sender, RadMenuEventArgs e)
{
Case = 2;
Arg1 = "%%";
Arg2 = e.Item.Value;
string query = "EXECUTE get_ndeshje_kot31 " + Case.ToString() + ", '" + Arg1 + "', '" + Arg2 + "', 0";
SqlDataSource MyDataSource = new SqlDataSource(ConfigurationManager.ConnectionStrings["basteConnectionString"].ConnectionString, query);
this.GridNdeshjet.DataSource = MyDataSource;
this.GridNdeshjet.DataBind();
}
3。页面“刷新”,RadGrid1中包含旧值+标签的默认文本为test。
我已经阅读了有关此事的所有Telerik API,并且徒劳地尝试了previuos解决方案。 有什么我想念的吗?还是忘了做?有谁知道为什么会发生这种情况?
关于AJAX,我的经理已经指示我不要“AJAX”这个页面。希望我的英语能够解决这个问题。
编辑:我有一个关于我的查询的PM,我已经在sqlserver管理工作室测试了它,它完全正常运行。我现在添加包含此控件的div的aspx代码,外面有标签,一些aspbutton,没有更多与此div的内容无关。
第二次编辑,以前的网格被更改为RadMenu。 Codebehind仍然是相同的,只与新菜单相关联。
<div>
<table>
<tr>
<td><asp:UpdatePanel ID="panelGetTeGjitha" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" >
<ContentTemplate>
<telerik:RadMenu ID="MenuKategoria" runat="server" DataSourceID="GetKategoriaDataSource"
DataTextField="kategoria" DataValueField="vlera" Flow="Vertical"
DataFieldID="kategoria"
onitemclick="MenuKategoria_ItemClick">
</telerik:RadMenu>
<asp:SqlDataSource ID="GetKategoriaDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:basteConnectionString %>"
SelectCommand="Get_Kategorite" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:SessionParameter DefaultValue="0" Name="Country" SessionField="country"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel></td>
<td><asp:UpdatePanel ID="panelGetKampionati" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" >
<ContentTemplate>
<telerik:RadMenu ID="MenuKampionati" runat="server" DataSourceID="GetKampionatiDataSource"
DataTextField="kampionati" DataValueField="kampionati" Flow="Vertical"
DataFieldID="kategoria" onitemclick="MenuKampionati_ItemClick" >
</telerik:RadMenu>
<asp:SqlDataSource ID="GetKampionatiDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:basteConnectionString %>" SelectCommand="SELECT kampionati FROM ndeshje (NOLOCK)
WHERE ((data > getdate() and ndeshje_id_live IS NULL) OR (data < getdate() AND data_hapjes > getdate() AND ndeshje_id_live IS NOT NULL))
AND bllokuar = '0' AND live = 0
GROUP BY kampionati ORDER by kampionati"></asp:SqlDataSource>
<telerik:RadGrid ID="GridNdeshjet" runat="server" GridLines="None"
onneeddatasource="GridNdeshjet_NeedDataSource1">
</telerik:RadGrid>
</ContentTemplate>
</asp:UpdatePanel></td>
<td><asp:UpdatePanel ID="panelGetNdeshje" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" >
<ContentTemplate>
<telerik:RadMenu ID="MenuNdeshjeLive" runat="server" DataSourceID="GetNdeshjeLiveDataSource"
DataTextField="Home" DataValueField="Home" Flow="Vertical"
DataFieldID="Home" onitemclick="MenuKampionati_ItemClick" >
</telerik:RadMenu>
<asp:SqlDataSource ID="GetNdeshjeLiveDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:basteConnectionString %>" SelectCommand="SELECT MAX(Home) AS Home, MAX(Away) AS Away FROM ndeshje (NOLOCK)
WHERE(Data < getdate() AND data_hapjes > getdate() AND ndeshje_id_live IS NOT null AND live = 1)
AND bllokuar = '0' GROUP BY Home, Away ORDER BY Home, Away"></asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel></td>
</tr>
</table>
答案 0 :(得分:0)
如果有任何疑虑,请告诉我。
<asp:UpdatePanel ID="panelGetKampionati" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<telerik:RadMenu ID="MenuKampionati" runat="server" DataTextField="Name" DataValueField="ID"
Flow="Vertical" DataFieldID="ID" OnItemClick="MenuKampionati_ItemClick">
</telerik:RadMenu>
<telerik:RadGrid ID="GridNdeshjet" runat="server" GridLines="None" OnNeedDataSource="GridNdeshjet_NeedDataSource1">
</telerik:RadGrid>
</ContentTemplate>
</asp:UpdatePanel>
..........
protected void MenuKampionati_ItemClick(object sender, RadMenuEventArgs e)
{
GridNdeshjet.Rebind();
}
protected void GridNdeshjet_NeedDataSource1(object sender, GridNeedDataSourceEventArgs e)
{
string strID = string.Empty; // just For Test
if (MenuKampionati.SelectedItem != null)
{
// Get Selected Records as per item selected in RadMenu
//Case = 2;
//Arg1 = "%%";
string Arg2 = MenuKampionati.SelectedItem.Value;
//string query = "EXECUTE get_ndeshje_kot31 " + Case.ToString() + ", '" + Arg1 + "', '" + Arg2 + "', 0";
//SqlDataSource MyDataSource = new SqlDataSource(ConfigurationManager.ConnectionStrings["basteConnection
strID = MenuKampionati.SelectedItem.Value; // just For Test
}
else
{
// Get All records From DB
}
// just For Test
dynamic data = new[] {
new { ID = 1, Name ="Name" + strID},
new { ID = 2, Name ="Name"+ strID},
new { ID = 3, Name ="Name"+ strID},
new { ID = 4, Name ="Name"+ strID},
new { ID = 5, Name ="Name"+ strID},
new { ID = 6, Name = "Name"+ strID}
};
GridNdeshjet.DataSource = data;
}