This is a migrated thread and some comments may be shown as answers.

[Solved] How to bind for insert via VB

1 Answer 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
bradley baker
Top achievements
Rank 1
bradley baker asked on 03 Nov 2009, 07:58 PM
I have two drop downs (The first AsgTo contains a list of people (it has duplicates) this is why the Value filed is set to the unique id).  I think take this ID and requery the same table for the 2nd drop down (This will be a hidden field that the users wont see).  But how do I make it so RadComboBox1 is bound to the field "procreq_asgto", I cant do "SelectValue=<%# Bind("procreq_asgto")%>" as it comes back with an error because Im binding int he VB code.  Ideas?

                <tr> 
                    <td style="width:25%;">  
                        Team</td> 
                    <td> 
                        <telerik:RadComboBox ID="AsgTo" runat="server" DataSourceID="Asg2SQL" AutoPostBack="true" 
                            DataTextField="mfgasgto_team" DataValueField="mfgasgto_id" MarkFirstMatch="true" EmptyMessage="Select One" 
                            OnSelectedIndexChanged="SelectedIndexChanged" AllowCustomText="true">  
                        </telerik:RadComboBox> 
                        <telerik:RadComboBox ID="RadComboBox1" runat="server" MarkFirstMatch="True">  
                        </telerik:RadComboBox> 
                    </td> 
                </tr>  

    Protected Sub SelectedIndexChanged(ByVal sender As ObjectByVal e As System.EventArgs)  
 
        'first reference the edited grid item through the NamingContainer attribute   
        Dim editedItem As GridEditableItem = CType(CType(sender, RadComboBox).NamingContainer, GridEditableItem)  
 
        Dim StatusBox As TextBox = CType(editedItem.FindControl("procreq_status"), TextBox)  
        Dim RequestorBox As RadTextBox = CType(editedItem.FindControl("RadTextBox4"), RadTextBox)  
        StatusBox.Text = "1" 
        RequestorBox.Text = Context.User.Identity.Name.ToString()  
 
        Dim PersonValue As RadComboBox = CType(editedItem.FindControl("AsgTo"), RadComboBox)  
        Dim PersonBox As RadComboBox = CType(editedItem.FindControl("RadComboBox1"), RadComboBox)  
        Asg2PersSQL.SelectCommand = "SELECT [mfgasgto_person] FROM [mfg_asgto] WHERE [mfgasgto_id] = " + PersonValue.SelectedValue  
        PersonBox.DataSource = Asg2PersSQL  
        PersonBox.DataTextField = "mfgasgto_person" 
        PersonBox.DataValueField = "mfgasgto_person" 
        PersonBox.DataBind()  
 
    End Sub 

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 06 Nov 2009, 09:34 AM
Hello bradley,

Even if you successfully use Bind() expression to associate the combo selected value, you are rebinding your combo when the first combo value changed. Thus, you will lose the binding. In your scenario, you will need to manually set the selected value of the second combo to the value of your data item. You can have a label with display:none in your column template containing the value which should be selected when the second combo binds. This, when you rebind the combo, you can find the label in the same container and set the combo's selected value.

Kind regards,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
bradley baker
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or