开发者

Datakeynames, request.querystring

开发者 https://www.devze.com 2023-03-14 10:44 出处:网络
I am doing something wrong in this small code Page1: ` protected void GridView1_OnRowDataBound(object sender, GridViewRowEventArgs e)

I am doing something wrong in this small code

Page1: `

protected void GridView1_OnRowDataBound(object sender, GridViewRowEventArgs e)
{

       UserType = DDlUserType.SelectedItem.Text;
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
           // Get the value in the hyperlink column.
           string HyperLinkValue = e.Row.Cells[1].Text;
           HyperLink myLink = new HyperLink();

           myLink.NavigateUrl = "~/ShowMMBProfileStats1.aspx?Profile_ID={0}";
           myLink.Text = HyperLinkValue;
}

In ShowMMBProfileStats1.aspx

开发者_Go百科
protected void Page_Load(object sender, EventArgs e)
{

        int MMBProfileID = Convert.ToInt32(Request.QueryString[0]);

}

It gives me an error

Input string was not in a correct format.

In the aspx page, I am assigning datakeynames="Profile_ID"

How do I carry this Profile_ID to page1. ` Thanks Sun


Try the following:

myLink.NavigateUrl = 
    "~/ShowMMBProfileStats1.aspx?Profile_ID=" + e.Row.Cells[profileIDCellIndex].Text;


You're not setting the value for {0}. Try something like this:

myLink.NavigateUrl = 
    String.Format("~/ShowMMBProfileStats1.aspx?Profile_ID={0}", HyperLinkValue );

or

 myLink.NavigateUrl = "~/ShowMMBProfileStats1.aspx?Profile_ID=" + HyperLinkValue ;
0

精彩评论

暂无评论...
验证码 换一张
取 消