GridView
|
|-----EmptyDataTemplate(空数据的模板)内放一个DetailsView
|
|-------DetailsView的一个模板列内的InsertItemTemplate内有放置 一个DropDowmList控件
|
|---------DropDowmList如何能在DetailsView的插入新数据时,获取到这个DropDowmList.selectedValue?
|
|-----EmptyDataTemplate(空数据的模板)内放一个DetailsView
|
|-------DetailsView的一个模板列内的InsertItemTemplate内有放置 一个DropDowmList控件
|
|---------DropDowmList如何能在DetailsView的插入新数据时,获取到这个DropDowmList.selectedValue?
解决方案 »
- Socket发送图片怎么解决?
- 关于GridView的数据绑定
- VS中C#调用AutoCAD绘图程序如何起步?
- 关于操作Excel后部署的恼人问题
- 在连接数据库时,如何显示未打开数据库的数据信息
- 头疼啊~为什么datagrid不显示
- 请问c#正则表达式中 / 是表示什么?
- 用vc++写的ocx控件,在vc.net中使用发现了很奇怪的问题?大家进来看看!
- 送大師50分,解決一個toolBar1r的問題 等等在線
- 为什么提示我这个错了radioButton1.Checked = false && radioButton2.Checked = false
- 有异常和没异常能不能有不同的处理方法?
- 向安全开炮??
{
DetailsView dv = sender as DetailsView;
DropDownList drp = dv.FindControl("MyDropDownListID") as DropDownList;
}
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</EditItemTemplate><ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("F01030102") >'>
</asp:Label>
</ItemTemplate>
希望达到的效果:
1.GridView显示的时候,用Label1现实行政区划的中文名称,如“XXX市”;
2.点击一行的“编辑”按钮时,该行切换到编辑状态,DropDownList1的已选中的Item为Label1中的现实的名称对应的选择.如:DropDownList1.Items.FindByText(“XXX市”).Selected = true;
问题:
protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
}
}
在这个事件下,如何能查找到该子控件,并获取Label1的值来完成Items的查找?说明,
DropDownList1的初始化已经完成,不用考虑。
{
Label Label1 = e.Item.FindControl("Label1") as Label;
if(Label1 != null)
{
DropDownList1.Items.FindByText(Label1.Text).Selected = true;}
}
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误信息: CS0117: “System.Web.UI.WebControls.GridViewCommandEventArgs”并不包含“Item”的定义
{
Label Label1 = e.Row.FindControl("Label1") as Label;
if(Label1 != null)
{
DropDownList1.Items.FindByText(Label1.Text).Selected = true;}
}
{
string sql = "SELECT * FROM NEM2_T01_03_01 ";
HybInfo.HybDAO.DynamicEntityService hybDAO = new HybInfo.HybDAO.DynamicEntityService();
//以上为数据库访问
Label Label1 = e.Row.FindControl("Label1") as Label;
DropDownList drp = (DropDownList)e.Row.FindControl("DropDownList1");
if (drp != null && Label1 != null)
{
drp.DataSource = hybDAO.QueryBySQL(sql).DataSource;
drp.DataTextField = "F01030102";
drp.DataValueField = "F01030101";
drp.DataBind();
drp.Items.FindByText(Label1.Text).Selected = true; }Label1 还是找不到
参照一下上面这个.