DataGrid里实现简单的行合并效果

ContractedBlock.gif ExpandedBlockStart.gif 在DataGrid里的ItemCreated事件时,重定向Render流
 1None.gifprivate void grdSearchResults_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
 2ExpandedBlockStart.gifContractedBlock.gif        dot.gif{
 3InBlock.gif            try
 4ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 5InBlock.gif                ListItemType itemtype = e.Item.ItemType;
 6InBlock.gif                if(itemtype == ListItemType.Item || itemtype == ListItemType.AlternatingItem)
 7ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
 8InBlock.gif                    BindSerialNum(e);
 9InBlock.gif                    //把主健值保存下来,为绑投标值用。
10InBlock.gif                    ViewState["PK_Cert_Info_ID"= grdSearchResults.DataKeys[e.Item.ItemIndex].ToString();
11InBlock.gif                    //投标值和分值特殊处理
12InBlock.gif                    e.Item.SetRenderMethodDelegate(new RenderMethod(NewRenderMethod));
13ExpandedSubBlockEnd.gif                }

14ExpandedSubBlockEnd.gif            }

15InBlock.gif            catch(Exception ex)
16ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
17InBlock.gif                Response.Write("<script>alert('"+ex.ToString()+"')</script>");
18ExpandedSubBlockEnd.gif            }

19ExpandedBlockEnd.gif        }
ContractedBlock.gif ExpandedBlockStart.gif 在自定义Render方法里实现效果
 1None.gif    private void NewRenderMethod(HtmlTextWriter writer, Control ctl)
 2ExpandedBlockStart.gifContractedBlock.gif        dot.gif{
 3InBlock.gif            //把前面的控件输出
 4InBlock.gif            for(int i = 0 ;i <= 5; i ++)
 5ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 6InBlock.gif                TableCell cell = (TableCell)ctl.Controls[i];
 7InBlock.gif                cell.RowSpan = 2;
 8InBlock.gif                cell.RenderControl(writer);
 9ExpandedSubBlockEnd.gif            }

10InBlock.gif            //得到特定资质下的所有投标值
11InBlock.gif            string PK_Cert_Info_ID = ViewState["PK_Cert_Info_ID"].ToString();
12InBlock.gif            DataTable dt = ProjectCert_BLL.SelectBidValuesByCertID(PK_Cert_Info_ID);
13InBlock.gif            
14InBlock.gif            //特别的输出投标值
15InBlock.gif            TableCell tablecell = (TableCell)ctl.Controls[6];
16InBlock.gif            if(tablecell != null)
17ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
18InBlock.gif                //遍历投标值
19InBlock.gif                foreach(DataRow row in dt.Rows)
20ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
21InBlock.gif                    //给DataGrid的投标值列手工绑定数据
22InBlock.gif                    Label lb = new Label();
23InBlock.gif                    lb.Text = row["BidValue_Name"].ToString();
24InBlock.gif                    tablecell.Controls.Add(lb);
25InBlock.gif                    //换行
26InBlock.gif                    LiteralControl lctr = new LiteralControl("<BR>");
27InBlock.gif                    tablecell.Controls.Add(lctr);
28ExpandedSubBlockEnd.gif                }

29InBlock.gif                //输出到HtmlTextWriter流中
30InBlock.gif                tablecell.RenderControl(writer);
31ExpandedSubBlockEnd.gif            }

32InBlock.gif            //特别的输出投标值的分值
33InBlock.gif            TableCell tablecell2 = (TableCell)ctl.Controls[7];
34InBlock.gif            if(tablecell2 != null)
35ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
36InBlock.gif
37InBlock.gif                for(int i=0;i<dt.Rows.Count;i++)
38ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
39InBlock.gif                    TextBox txtBidValue = new TextBox();
40InBlock.gif                    txtBidValue.CssClass = "TextBox";
41InBlock.gif                    txtBidValue.ID = txtBidValue+i.ToString();
42InBlock.gif                    tablecell2.Controls.Add(txtBidValue);
43InBlock.gif                    //换行
44InBlock.gif                    LiteralControl lctr = new LiteralControl("<BR>");
45InBlock.gif                    tablecell2.Controls.Add(lctr);
46ExpandedSubBlockEnd.gif                }

47InBlock.gif                //输出到HtmlTextWriter流中
48InBlock.gif                tablecell2.RenderControl(writer);
49ExpandedSubBlockEnd.gif            }

50ExpandedBlockEnd.gif        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值