con是一个参数,我想通过con传递一个DIV的ID值进去,然后返回,该怎么改啊! 
   protected void MarkLink(Object con)
    {
        string templelink ="<LI><p class=ico id=getsmpic></p><P class=img><a target=_blank href={0}><IMG src={1} alt={2} border=0 /></a></P><P class=name><A title={3} href=/vvshopProductView/pid-18992.jhtml target=_blank>{4}<span class=red></span></A></P><P class=price><FONT class=et_price>{5}</FONT><BR>为为价:<b></b>{6} 元<BR></P></LI>";
        string result1 = "";
        List<listParam> list = GetList();
        foreach (listParam lp in list)
        {
            result1 += string.Format(templelink, lp.src, lp.src, lp.title, lp.title, lp.title, lp.title, lp.title);
        }
       return con.InnerHtml = result1;         
    }

解决方案 »

  1.   

    使用out 关键字out Object con
      

  2.   

    相关DEMO
      

  3.   

    不行啊!错误:
    错误 34 “object”不包含“InnerHtml”的定义,并且找不到可接受类型为“object”的第一个参数的扩展方法“InnerHtml”(是否缺少 using 指令或程序集引用?) i:\mysql\App_Code\Class1.cs 83 19 i:\mysql\
      

  4.   

    protected void MarkLink(Object con)
      {
      string templelink ="<LI><p class=ico id=getsmpic></p><P class=img><a target=_blank href={0}><IMG src={1} alt={2} border=0 /></a></P><P class=name><A title={3} href=/vvshopProductView/pid-18992.jhtml target=_blank>{4}<span class=red></span></A></P><P class=price><FONT class=et_price>{5}</FONT><BR>为为价:<b></b>{6} 元<BR></P></LI>";
      string result1 = "";
      List<listParam> list = GetList();
      foreach (listParam lp in list)
      {
      result1 += string.Format(templelink, lp.src, lp.src, lp.title, lp.title, lp.title, lp.title, lp.title);
      }
      return con.InnerHtml = result1;  
      }
    你看你的方法都没返回值。要么你用out 要么就加个返回值类型。
      

  5.   

    源程序如下:请大家看看,这个问题怎么解决。
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.IO;
    using System.Data;
    using System.Configuration;
    using MySql.Data;
    using MySql.Data.MySqlClient;/// <summary>
    ///Class1 的摘要说明
    /// </summary>
    public class Class1
    {
    public Class1()
    {
    //
    //TODO: 在此处添加构造函数逻辑
    //         public struct listParam
        {
            public string url
            {
                get;
                set;
            }
            public string src
            {
                get;
                set;
            }
            public string title
            {
                get;
                set;
            }    }
        /// <summary>
        /// 读取数据库产品数据
        /// </summary>
        /// <returns></returns>
        public List<listParam> GetList()
        {
            List<listParam> result=new List<listParam>();
            listParam lp;
            try
            {
                string conn = ConfigurationManager.ConnectionStrings["520tuanConnectionString"].ConnectionString;
                MySqlConnection con = new MySqlConnection(conn);
                con.Open();
                string sql = "select * from product";
                MySqlCommand cmd = new MySqlCommand(sql,con);
                MySqlDataReader reader = cmd.ExecuteReader();
                while(reader.Read())
                {
                    lp = new listParam();
                    lp.url = "";
                    lp.src = reader["src"].ToString();
                    lp.title = reader["title"].ToString();
                    result.Add(lp);
                }
                reader.Close();
                con.Clone();
            }
            catch(Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return result;
        }    protected void MarkLink( out Object con)
        {
            string templelink ="<LI><p class=ico id=getsmpic></p><P class=img><a target=_blank href={0}><IMG src={1} alt={2} border=0 /></a></P><P class=name><A title={3} href=/vvshopProductView/pid-18992.jhtml target=_blank>{4}<span class=red></span></A></P><P class=price><FONT class=et_price>{5}</FONT><BR>价格:<b></b>{6} 元<BR></P></LI>";
            string result1 = "";
            List<listParam> list = GetList();
            foreach (listParam lp in list)
            {
                result1 += string.Format(templelink, lp.src, lp.src, lp.title, lp.title, lp.title, lp.title, lp.title);
            }
           return con.InnerHtml = result1;  
            
        }
    }
    }
      

  6.   

    问题终于解决了,现将解决方法告诉大家
     protected void MarkLink(HtmlGenericControl str)
        {
            string templelink ="<LI><p class=ico id=getsmpic></p><P class=img><a target=_blank href={0}><IMG src={1} alt={2} border=0 /></a></P><P class=name><A title={3} href=/vvshopProductView/pid-18992.jhtml target=_blank>{4}<span class=red></span></A></P><P class=price><FONT class=et_price>{5}</FONT><BR>为为价:<b></b>{6} 元<BR></P></LI>";
            string result1 = "";
            List<listParam> list = GetList();
            foreach (listParam lp in list)
            {
                result1 += string.Format(templelink, lp.src, lp.src, lp.title, lp.title, lp.title, lp.title, lp.title);        }
            //str = new HtmlGenericControl();
            str.InnerHtml = result1;         
        }
      

  7.   

    是啊,很久没有完asp.net了,很多东西早已忘记得一干二净了,现在要用,却发现脑袋空空的,又得从头来过。
    谢谢,各位的热心帮助与提醒。
      

  8.   

    你既然给函数 定义了void  ,他就不会返回任何东西,那你就只能使用out 或者使用全局变量或者就把void改成 string