关于GV传参
我设置一个GV~~~~有一个是绑定了一个表的内容的;如下:---------------------------------------------------------------------------
//这是Ms的
</asp:TemplateField>
<asp:TemplateField HeaderText="消息内容" SortExpression="Content">
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" Text='<%# MessageSubString(Eval("Content").ToString())%>'
CommandArgument=<%# Eval("MessageId") %> CommandName="Ms"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
//这是Ed的
asp:TemplateField HeaderText="修改">
<ItemTemplate>
<asp:ImageButton ID="imgbtnEd" runat="server" CommandArgument=<%#Eval("MessageId") %> CommandName="Ed" ImageUrl="~/images/edit.gif" />
</ItemTemplate>
</asp:TemplateField>
---------------------------------------------------------------------------
代码页:
---------------------------------------------------------------------------
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
string commandName = e.CommandName.ToString();
string messageId = e.CommandArgument.ToString();
if (commandName=="Ed")
{
Response.Redirect("SaveMessage.aspx?MessageId=" + messageId);
}
else if (commandName == "Ms")
{
Response.Redirect("Message.aspx?MessageId" + messageId);
}
else if (commandName == "De")
{
if (MessageManager.DeleteMessageById(Convert.ToInt32(messageId)))
{
this.GridView1.DataSource = null;
this.GridView1.DataSourceID = "odsMessage";
this.GridView1.DataBind();
}
else
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('员工信息删除失败!');</script>");
}
}
}
---------------------------------------------------------------------------
传参页我这样接收:
---------------------------------------------------------------------------
//Message页
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int messageId = Convert.ToInt32(Request.QueryString["MessageId"]);
Message message = MessageManager.GetContentByMessageId(messageId);
this.TextBox1.Text = message.Content.ToString();
}
}
//SaveMessage页
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int messageId = Convert.ToInt32(Request.QueryString["MessageId"]);
Message message = MessageManager.GetMessageByMsgId(messageId);
this.txtTitle.Text = message.Title.ToString();
this.DropType.SelectedValue = message.Type.MessageTypeId.ToString();
this.txtBeginTime.Text = Convert.ToDateTime(message.BeginTime).ToString();
this.txtEndTime.Text = Convert.ToDateTime(message.EndTime).ToString();
this.txtContent.Text = message.Content.ToString();
}
}
---------------------------------------------------------------------------
为什么我(commandName=="Ms")传过去后显示是在位置 0 处没有任何行。我(commandName=="Ed")那个却能正确把MessageId传过去呢?
求个答案~~不要其他方法~~~我就先知道这个方法错在哪里?请高手解答下~~~~在线等!! --------------------编程问答-------------------- 没有人回答下我吗???
补充:.NET技术 , ASP.NET