在visulastudio 2012中的intellisense报告中未显示控件ID [英] Control id's are not show on intellisense report in visulastudio 2012
问题描述
一般情况下我用gridview开发应用程序但我的意图gridview编辑更新delete.in gridview我曾经使用过fileupload控件。这个控件只有在编辑事件执行时才可见。实际上我在gridview中有图像和视频这就是为什么我在gridview中使用了2个fileupload控件。在文件fileupload控件后面的代码中编写代码控件id不会在intellisense中显示
我的代码:
Generally i had develop the application with gridview but my intention gridview edit update delete.in that gridview i had used fileupload control .this control are visible only whenever edit event performed.actually i had the images and videos in gridview thats why i had used 2 fileupload controls in the gridview.while writing the code in code behind file fileupload controls id will not shown in intellisense
my code:
<pre><asp:GridView ID="GridView1" runat="server" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnRowDeleting="GridView1_RowDeleting" AutoGenerateColumns="false" style="height: 664px; width: 624px; z-index: 1; left: 335px; top: 452px; position: absolute" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None">
<RowStyle Height="100px" Width="100px" />
<AlternatingRowStyle BackColor="PaleGoldenrod" />
<Columns>
<asp:BoundField DataField="alphabet_id" HeaderText="id" ReadOnly="true" />
<asp:BoundField DataField="letter" HeaderText="Alphabetname" ReadOnly="true" />
<asp:TemplateField HeaderText="example" HeaderStyle-Width="100px">
<ItemTemplate>
<asp:FileUpload ID="fileUpload1" runat="server" Visible="false" />
<br />
<asp:Button runat="server" ID="btnload1" Text="Uploadimage" Visible="false" OnClick="btnload1_Click" />
<asp:Image ID="Image1" runat="server" ImageUrl='<%# Bind("example") %>' Width="100px"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="expression" HeaderStyle-Width="100px">
<ItemTemplate>
<asp:FileUpload ID="fpload" runat="server" Visible="false"/>
<br />
<asp:Button runat="server" ID="btnload" Text="uploadvideo" Visible="false" />
<video width="200" height="200" controls="controls">
<source src="<%# Eval("letter") %>" type="video/mp4" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:LinkButton ID="btnEdit" runat="server" CausesValidation="false" CommandName="Edit" Text="Edit"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Update">
<ItemTemplate>
<asp:LinkButton ID="lnkbtnUpdate" runat="server" CausesValidation="true" Text="Update" CommandName="Update"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="lnkbtnCancel" runat="server" CausesValidation="false" Text="Cancel" CommandName="Cancel"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="Tan" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<SortedAscendingCellStyle BackColor="#FAFAE7" />
<SortedAscendingHeaderStyle BackColor="#DAC09E" />
<SortedDescendingCellStyle BackColor="#E1DB9C" />
<SortedDescendingHeaderStyle BackColor="#C2A47B" />
</asp:GridView>
代码隐藏文件
Code behind file
using System;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class UpdateAlphabets : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindData();
}
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
BindData();
FileUpload fup = GridView1.Rows[e.NewEditIndex].FindControl("fpload1") as FileUpload;
FileUpload fup1 = GridView1.Rows[e.NewEditIndex].FindControl("fpload") as FileUpload;
Button btn = (Button)GridView1.Rows[e.NewEditIndex].FindControl("btnload1");
Button btn1 = (Button)GridView1.Rows[e.NewEditIndex].FindControl("btnload");
fup.Visible = true;
fup1.Visible = true;
btn.Visible = true;
btn1.Visible = true;
//e.Row.Cells[3].Visible = false;
//e.Row.Cells[5].Visible = false;
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
}
public void BindData()
{
SqlConnection con1 = new SqlConnection(WebConfigurationManager.ConnectionStrings["con1"].ToString());
SqlDataAdapter da = new SqlDataAdapter("select * from alphabet", con1);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void btnload1_Click(object sender, EventArgs e)
{
}
}
< br $>
i无法在btnload1_Click事件中编写代码,因为fileupload控制的id不会在intellisense中显示
已经重启视觉工作室和操作系统,但我有同样的问题。
请帮帮我。
谢谢你。
我的尝试:
i can't write the code in btnload1_Click event because fileupload controld id's not show in intellisense
Already restart visual studio and operating system but i have same problem.
please help me.
thank u.
What I have tried:
Generally i had develop the application with gridview but my intention gridview edit update delete.in that gridview i had used fileupload control .this control are visible only whenever edit event performed.actually i had the images and videos in gridview thats why i had used 2 fileupload controls in the gridview.while writing the code in code behind file fileupload controls id will not shown in intellisense
推荐答案
原因是它们在 GridView $ c $里面c>当在浏览器上呈现时,会有很多 FileUpload
控件,因为每行包含它们。
所以,要在代码后面识别它们,你必须使用 FindControl
。
The reason is they are insideGridView
and when rendered on browser, there will be manyFileUpload
controls because each row contains them.
So, to identify them in code behind you have to useFindControl
.
这篇关于在visulastudio 2012中的intellisense报告中未显示控件ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!