本文介绍了如何读取网格中的dropdownlist值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的GridView,这里看到的名为GridView1



其中我有一个名为DropDownList1的下拉列表



< asp:TemplateField HeaderText =辅导员选择>

< itemtemplate>

< asp:DropDownList ID =DropDownList1Width = 100%runat =serverDataSourceID =SqlDataSource2DataTextField =user_nameDataValueField =user_nameAutoPostBack =TrueAppendDataBoundItems =true>

< asp:ListItem Text = - 选择 - 值=>



< asp:SqlDataSource ID =SqlDataSource2runat =serverConnectionString =<% $ ConnectionStrings:ocean4d_devConnectionString%> SelectCommand =SELECT [user_name] FROM [AgencyUser] WHERE([agency_id] = @agency_id)>

< SelectParameters>

< asp:SessionParameter Name = agency_idSessionField =agency_idType =Int32/>

< / SelectParameters>









如何在asp.net VisualBasic中读取它的价值?



我知道什么时候它是一个正常的下拉列表我会输入类似



respose.write(dropdownlist1.selectedvalue)



任何人都可以提供帮助吗?



Tnx

I have very simple GridView as seen here called GridView1

Inside of it I have dropdown list called DropDownList1

<asp:TemplateField HeaderText="Counselors Selection">
<itemtemplate>
<asp:DropDownList ID="DropDownList1" Width="100%" runat="server" DataSourceID="SqlDataSource2" DataTextField="user_name" DataValueField="user_name" AutoPostBack="True" AppendDataBoundItems="true">
<asp:ListItem Text="--Select--" Value="">

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ocean4d_devConnectionString %>" SelectCommand="SELECT [user_name] FROM [AgencyUser] WHERE ([agency_id] = @agency_id)">
<SelectParameters>
<asp:SessionParameter Name="agency_id" SessionField="agency_id" Type="Int32" />
</SelectParameters>




How can I in asp.net VisualBasic read the value of it?

I know when it is a normal dropdownlist I would type something like

respose.write(dropdownlist1.selectedvalue)

Anyone can help?

Tnx

推荐答案


protected void YourGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
  DropDownList ddl= (DropDownList )YourGrid.Rows[e.RowIndex].FindControl("ddlId");
  string selectedvalue=ddl.selectedvalue;
 }



这篇关于如何读取网格中的dropdownlist值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 08:06