用Repeater呈现数据,首列HtmlSelect可选,想是想的功能就是选择HtmlSelect之后,本行数据做相应的改变不想通过后台遍历Repeater行Item的方式做,请问可否直接传递HtmlSelect控件到C#端进行相应处理?希望大家不吝赐教,谢谢!

解决方案 »

  1.   

    补充一点:Repeater表单内容是动态生成的,如下:protected void Rp_Show_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            int num = 0;
            if (e.Item.ItemType == ListItemType.Header)//表头输出
            {
                string strHeader = "<table width=\"100%\" cellspacing=\"0\" style=\" word-break:break-all;\"><tr style=\"width:100%\">";            strHeader += "<td style=\"width:15%; text-align:center;\">下拉测试</td>";            foreach (DataColumn dc in this.TestDT().Columns)
                {
                    strHeader += "<td style=\"width:15%; text-align:center;\">" + dc.ColumnName + "</td>";
                }
                strHeader += "</tr></table>";            Literal liteHeader = e.Item.FindControl("lite_Header") as Literal;
                if (liteHeader != null)
                {
                    liteHeader.Text = strHeader;
                }
            }
            else if (e.Item.ItemType == ListItemType.Item)//表体输出
            {
                string strItem = "<table width=\"100%\" cellspacing=\"0\" style=\" word-break:break-all;\">";            foreach (DataRow dr in this.TestDT().Rows)
                {
                    strItem += "<tr style=\"width:100%\">";                strItem += "<td style=\"width:15%; text-align:center;\">";
                    strItem += "<select id=\"sel"+num.ToString()+"\" onchange=\"ajaxChange(this);\" class='colorblur' onfocus=" + "this.className='colorfocus';" + " onblur=" + "this.className='colorblur';" + " runat='server'>";
                    foreach (DataRow row in this.TestDT().Rows)
                    {
                        strItem += "<option value='" + row["Name"].ToString() + "'>" + row["Name"].ToString() + "</option>";
                    }
                    strItem += "</select></td>";
                    foreach (DataColumn dc in this.TestDT().Columns)
                    {
                        //strItem += "<td style=\"width:15%; text-align:center;\"><asp:TextBox ID=\"" + dc.ColumnName + "\" Text='" + dr[dc.ColumnName].ToString() + "' runat=\"server\" Width=\"80px\" class=\"colorblur\" onfocus=\"this.className='colorfocus';\" onblur=\"this.className='colorblur';\"></asp:TextBox></td>";
                        strItem += "<td style=\"width:15%; text-align:center;\">";
                        strItem += "<input id=\"" + dc.ColumnName+num.ToString() + "\" value=\"" + dr[dc.ColumnName].ToString() + "\" class='colorblur' onfocus=" + "this.className='colorfocus';" + " onblur=" + "this.className='colorblur';" + " type='text' runat='server' /></td>";
                        //strItem += "<td style=\"width:15%; text-align:center;\">" + dr[dc.ColumnName].ToString() + "</td>";
                    }
                    strItem += "</tr>";
                    num++;
                }
                strItem += "</table>";            Literal liteItem = e.Item.FindControl("lite_Item") as Literal;
                if (liteItem != null)
                {
                    if (cnt == 0)
                    {
                        liteItem.Text = strItem;
                    }
                    cnt++;
                }
            }