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

Edit Mode in Grid...

4 Answers 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sanjeev
Top achievements
Rank 1
sanjeev asked on 16 Feb 2009, 03:27 PM
i have list box in ascx.cs ..in edit mode the selected values are not binding in list box..is tr any to bind by coding or someother option...

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Feb 2009, 06:19 AM
Hi Sanjeev,

I hope the link to the online demo which shows user control edit form will help you. Check-out the link below.
User control edit form

Thanks,
Shinu.
0
Princy
Top achievements
Rank 2
answered on 17 Feb 2009, 07:43 AM
Hello Sanjeev,

You can also check out the following code to set the SelectedValue of the ListBox in the ascx:
ascx:
<asp:ListBox ID="ListBox1" DataSourceID="SqlDataSource1"  DataTextField="ProductName" SelectedValue='<%#Eval("ProductName")%>' DataValueField="ProductName" runat="server"></asp:ListBox> 

Thanks
Princy.
0
sanjeev
Top achievements
Rank 1
answered on 17 Feb 2009, 09:18 AM
i'm using custom binding in ascx.cs so selectedvalue is not tr in listbox....
0
Princy
Top achievements
Rank 2
answered on 18 Feb 2009, 05:20 AM
Hello Sanjeev,

You can set the SelectedIndex of the ListBox in the code behind of the page that contains the grid as shown below inorder to select a listbox value corresponding to the row:
aspx.cs:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem editItem = (GridEditableItem)e.Item; 
            UserControl userControl = (UserControl)editItem.FindControl(GridEditFormItem.EditFormUserControlID); 
            ListBox listbx = (ListBox)userControl.FindControl("ListBox1"); 
            listbx.SelectedIndex = editItem.ItemIndex; 
        } 
    } 

Thanks
Princy.
Tags
Grid
Asked by
sanjeev
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Princy
Top achievements
Rank 2
sanjeev
Top achievements
Rank 1
Share this question
or