More Group Sites
School Rankings
Jobless Net
Better Home
Enviro++


Help | Subscribe/Unsubscribe | Rules | Other Group Sites: Better Education | Better Education Forum
Welcome Guest Search | Active Topics | Members | Log In | Register

How to set default value in dropdownlist from databound items Options · View
hong
Posted: Tuesday, May 24, 2011 6:43:23 AM

Rank: Administration
Groups: Administration

Joined: 11/23/2008
Posts: 335
Points: 711
Location: Australia
For example, one column in your datagridview is implemented as dropdownlist which is bound to a datasource. There are no methods or properties for DataGridViewComboBoxCell to set the default value. However, we can set its default value in the UserAddedRow event handler of datagridview:
Code:
        private void dataGridViewDoorReader_UserAddedRow(object sender, DataGridViewRowEventArgs e)
        {
            int nIndex = e.Row.Index - 1;
            DataGridViewRow row = dataGridViewDoorReader.Rows[nIndex];
           
            //set your default value here
            row.Cells["ddlColumnName"].Value = defaultValue;
        }

Sponsor
Posted: Tuesday, May 24, 2011 6:43:23 AM
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

ASPNET Theme created by Boskone (Dan Ferguson)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.
This page was generated in 0.261 seconds.