在gridview中有一个转发器,但是有两个不同的数据源 [英] Having a repeater within a gridview but having two different datasources

查看:49
本文介绍了在gridview中有一个转发器,但是有两个不同的数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想知道如何执行以下操作,我有一个带有Image和binddata的gridview,我想在网格视图中放置一个转发器,但是使用另一个数据源,使用由Gridview数据源返回的值来填充转发器,这可能吗? />
问候
在此先感谢.

Hi
I would like to know how to do the following, I have a gridview with Image and binddata I want to place a repeater within the gridview but use a different datasource to populate the repeater using values returned by the Gridview datasource is this possible?

Regards
thanks in advance.

推荐答案

yep
使用gridview RowDataBound

yep
use gridview RowDataBound

protected void grv_RowDataBound(object sender, GridViewRowEventArgs e)
{
    switch (e.Row.RowState)
    {
        case DataControlRowState.Normal:
        case DataControlRowState.Alternate:
        case DataControlRowState.Edit:
            int idField = Convert.ToInt16(DataBinder.Eval(e.Row.DataItem, "idField"));
            Repeater rep= (Repeater )e.Row.FindControl("idRepeater");
            rep.DataSource = yourdatasource;
            rep.DataBind();
            break;
    }
}



我不知道您是否总是需要绑定或仅在编辑模式下需要绑定.

使用不同的情况来更改行为



i don''t know if u need the bind always or only in edit mode.

use different cases to change that behaviour


<asp:gridview id="GrdJobSht" runat="server" autogeneratecolumns="False" datasourceid="GetJobSheetDATA" xmlns:asp="#unknown">
 <columns>
  <asp:templatefield>
    <itemtemplate>  
      <table>
      <tr>
      <td rowspan="5" class="style4">
       <asp:image id="ProdImage" runat="server" height="152px" imageurl="<%# String.Format(ResolveUrl("ProductImage.ashx")+"{0}{1}","?id=",Eval("propImageId"))%>" style="margin-left: 0px" width="172px" bordercolor="Silver" borderstyle="Double" borderwidth="10pt" /> 
</td>                                              
</tr>
<tr>
<td class="style5">
<asp:label id="Label1" runat="server" text="Product ID:" font-italic="True">
 Font-Names="Times New Roman" Font-Size="Medium"></asp:label>
 </td>
 <td>
  <asp:label id="lblProdid" runat="server" text="<%# Eval("propProdId") %>"></asp:label>
 </td>
 </tr>
 <tr>
 <td class="style5">
 <asp:label id="Label2" runat="server" text="Description:" font-italic="True">
 Font-Names="Times New Roman" Font-Size="Medium"></asp:label>
 </td>
 <td>
   <asp:label id="lblDesc" runat="server" text="<%# Eval("propProdDesc") %>"></asp:label>
 </td>
 </tr>
 <tr>
 <td class="style5">
 <asp:label id="Label3" runat="server" text="Quantity:" font-italic="True">
 Font-Names="Times New Roman" Font-Size="Medium"></asp:label>
 </td>
 <td>
  <asp:label id="lblQty" runat="server" text="<%# Eval("propProdQty") %>"></asp:label>
 </td>
 </tr>
 <tr>
 <td class="style5">
 <asp:label id="Label4" runat="server" text="Colour:" font-italic="True">
 Font-Names="Times New Roman" Font-Size="Medium"></asp:label>
 </td>
 <td>
   <asp:label id="lblColor" runat="server" text="<%# Eval("propColour") %>"></asp:label>
 </td>
 </tr>
 <tr>
 <td class="style5">
  <asp:label id="Label5" runat="server" text="Def Design:" font-italic="True">
  Font-Names="Times New Roman" Font-Size="Medium"></asp:label>
  </td>
  <td>
   <asp:label id="lblDefDes" runat="server" text="<%# Eval("propDeflectionDesign") %>"></asp:label>
 </td>
 </tr></table>
 </itemtemplate>
</asp:templatefield>
</columns>
</asp:gridview>
<asp:objectdatasource id="GetJobSheetDATA" runat="server" selectmethod="GetJobSheet" typename="BusinessLogicLayer.QuoteProduct" xmlns:asp="#unknown">
  <selectparameters>
   <asp:controlparameter controlid="DDlQno" defaultvalue="129126" name="Qno" propertyname="SelectedValue" type="Int32" />
  </selectparameters>
  </asp:objectdatasource>



我想添加一个中继器,该中继器将在检索其自己的数据时使用"propProdId"和"DDlQno"作为参数



I want to add a repeater that will use "propProdId" and "DDlQno" as parameters in retrieving its own data


这篇关于在gridview中有一个转发器,但是有两个不同的数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆