首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

在cs文件中如何取页面上的GridView控件模板中用户控件里的DropDownList控件的值

2012-01-22 
在cs文件中怎么取页面上的GridView控件模板中用户控件里的DropDownList控件的值?--------------------DDLi

在cs文件中怎么取页面上的GridView控件模板中用户控件里的DropDownList控件的值?
--------------------DDList.ascx-----------------

                        <asp:DropDownList   ID= "DropDownList1 "   runat= "server "   AutoPostBack= "True "   DataSourceID= "SqlDataSource1 "
                                DataTextField= "lbname "   DataValueField= "lbid "   OnSelectedIndexChanged= "DropDownList1_SelectedIndexChanged ">
                        </asp:DropDownList>
                        <atlas:UpdatePanel   ID= "UpdatePanel1 "   runat= "server ">
                                <ContentTemplate>
                                          <asp:DropDownList   ID= "DropDownList2 "   runat= "server ">
                                        </asp:DropDownList>
                                </ContentTemplate>
                                <Triggers>
                                        <atlas:ControlEventTrigger   ControlID= "DropDownList1 "   EventName= "SelectedIndexChanged "   />
                                </Triggers>
                        </atlas:UpdatePanel>
      ---------------------------------------index.aspx----------------------------------------

<asp:GridView   ID= "GridView1 "   runat= "server "   AutoGenerateColumns= "False "   DataSourceID= "SqlDataSource1 ">
                        <Columns>
                                <asp:TemplateField   HeaderText= "分类 ">
                                        <EditItemTemplate>
                                                <asp:TextBox   ID= "TextBox1 "   runat= "server "> </asp:TextBox>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                                <uc1:DDList   ID= "DDList1 "   runat= "server "   />


                                        </ItemTemplate>
                                </asp:TemplateField>
                        </Columns>
                </asp:GridView>    

-----------------------------------------   index.aspx.cs   ------------

在cs文件里怎么取DDList1用户控件的DropDownList1和DropDownList2控件的值???


[解决办法]
直接在调用页面访问就可以了.
[解决办法]

public class DDList : userControl
{
public string SelectValue1
{
get
{
return DropDownList1.SelectedValue;
}
}


....

}

DDList d = GridView1.Rows[n].FindControl( "DDList1 ") as DDList;
string s = d.SelectedValue1;


热点排行