由于网格项目命令的事件未执行,因此我无法在此处猜测此问题。我也更改了pageevent验证状态但无用。 我粘贴的.aspx代码以及 网格是完全绑定无法启动onItemCommand事件
<telerik:RadGrid ID="frds" runat="server" OnItemCommand="go_frd" AutoGenerateColumns="false" >
<MasterTableView>
<Columns>
<telerik:GridTemplateColumn>
<ItemTemplate>
<asp:Button ID="bt" runat="server" CommandArgument='<%#Eval("frd_ID") %>' Text="test" />
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
事件是这样的
protected void go_frd(object o, GridCommandEventArgs e)
{
if (e.CommandName == "frd_go")
{
Response.Redirect("Profiling.aspx?uid=" + e.CommandArgument);
}
if (e.CommandName == "add_frd")
{
db_accessDataContext db = new db_accessDataContext();
Frd_request req = new Frd_request();
db.AddFriend(Int64.Parse(cur_mem_id), Int64.Parse(e.CommandArgument.ToString()));
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("dbo.addFriend", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(@"memID", Int64.Parse(cur_mem_id));
cmd.Parameters.Add(@"frdID", Int64.Parse(e.CommandArgument.ToString()));
try
{
con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex) { }
}
}
我试过很多方法,但不能火按钮事件电网 我通过放置一个中断点来检查它,问题在于它甚至没有开始执行事件 绑定COde
string query = "my query containing the frd_id ,works fine in query builder and it also is shown grid view ";
try { SqlConnection con = new SqlConnection(connectionString);
SqlDataAdapter adapter = new SqlDataAdapter(query, con);
adapter.Fill(d0); con.Close();
} catch (Exception ex) { }
frds.DataSource = d0;
frds.DataBind();
我通过放置一个断点来检查它,麻烦的是它甚至没有开始执行事件 –
你如何绑定网格? –
字符串查询=“我的查询包含frd_id,在查询生成器中工作正常,它也显示网格视图”; 尝试 SqlConnection con = new SqlConnection(connectionString); SqlDataAdapter adapter = new SqlDataAdapter(query,con); adapter.Fill(d0); con.Close(); } catch(Exception ex){} frds.DataSource = d0; frds.DataBind(); –