Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<ASP:DROPDOWNLIST> behavior

Status
Not open for further replies.

JGresko

Programmer
Apr 24, 2002
86
US
What it's supposed to do:

I have a page that has some textboxes and 3 dropdown lists on it. After the user fills/selects their values, they hit an Add button to transfer the values into a datagrid at the bottom of the page. The textboxes ase just plain INPUT fields, the Dropdown lists are being filled by simple SQL in the Page_Load event, and the DataGrid is also being defined in the Page_Load event... nothing fancy, see HTML below.

<INPUT id=Grant type=text maxLength=20 size=20 name=Grant>
<ASP:DROPDOWNLIST id=lstType runat=&quot;server&quot; DataValueField=&quot;CODTYP&quot; datatextfield=&quot;LIBTGB&quot;></ASP:DROPDOWNLIST>
<ASP:DATAGRID id=dgCriteria runat=&quot;server&quot;></ASP:DATAGRID>

What it's doing:

When the Add button is clicked the field names and their associated values are transfered like they should be, except the values from the dropdowns. The dropdown field names transfer as they should if a value has been selected, but the selected values don't show up in the datagrid. The page knows it's been selected because the field name shows up. Can anyone see why it's behaving this way?

Judy


Private Sub cmdAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
Dim scRow As DataRow

If Request(&quot;Grant&quot;) <> &quot;&quot; Then
scRow = dGrid.NewRow()
scRow(&quot;Field&quot;) = &quot;Grant #&quot;
scRow(&quot;Value&quot;) = Request(&quot;Grant&quot;)
dGrid.Rows.Add(scRow)
dGridView = New DataView(dGrid)
dgCriteria.DataSource = dGridView
dgCriteria.DataBind()
End If

If lstType.SelectedItem.Text <> &quot; &quot; Then
scRow = dGrid.NewRow()
scRow(&quot;Field&quot;) = &quot;Type&quot;
scRow(&quot;Value&quot;) = lstType.SelectedItem.Text
dGrid.Rows.Add(scRow)
dGridView = New DataView(dGrid)
dgCriteria.DataSource = dGridView
dgCriteria.DataBind()
End If

End Sub
 
oops, nevermind, I had the dropdown binding outside the &quot;If Not IsPostBack&quot; and they were being reset before the values were recorded.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top