ListView控件使用LINQ数据源插入模板 [英] ListView with LINQ Datasource insert template

查看:188
本文介绍了ListView控件使用LINQ数据源插入模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来这应该是简单的,但我难以置信。我有我的列表视图的所有设置和绑定到我LINQ数据源。来源取决于它决定ListView中显示哪些分支信息的下拉列表中。我编辑模板工作正常,但我插入模板将无法工作,因为它想,我想从列表视图外DropDownList中获得分支ID,但我不知道如何结合两者的价值,并将其设置在我的模板。它看起来是这样的:

It seems like this should be straightforward but I'm boggling. I've got my listview all setup and bound to my LINQ datasource. The source is dependent on a dropdown list which decides which branch information to show in the listview. My edit template works fine but my insert template won't work because it wants the branch ID which I want to get from the dropdownlist outside the listview but I don't know how to both bind that value and set it in my template. It looks like this:

<InsertItemTemplate>
    <tr style="">
      <td>
         <asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
               Text="Insert" />
     </td>
      <td>
       <asp:TextBox ID="RechargeRateTextBox" runat="server" 
          Text='<%# Bind("RechargeRate") %>' />
         </td>
              <td>
       <asp:Calendar SelectedDate='<%# Bind("StartDate") %>' ID="Calendar1"  runat="server"></asp:Calendar>                                    
       </td>
           </tr>
    </InsertItemTemplate>

我需要得到一个标签有结合数据绑定的ASP DropDownList中的值列表视图之外,这样的插入会工作。

I need to get a label in there that binds to the value of a databound asp dropdownlist outside of the listview so that the insert will work.

推荐答案

我结束了这个打算,感谢twanfosson。

I ended up going with this, thanks twanfosson.

protected void ListView1_ItemInserting(object sender, System.Web.UI.WebControls.ListViewInsertEventArgs e)
        {
            e.Values["BranchID"] = DropDownList1.SelectedValue;
        }

这篇关于ListView控件使用LINQ数据源插入模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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