Problem with combobox in datagridview

Posted by Mahesh_Chs under C# on 9/15/2012 | Points: 10 | Views : 2336 | Status : [Member] | Replies : 4
hi,

i have a combobox in datagridview control, the prooblem is how can i get the selected value from combobox...
the combobox contains id values of my table




Responses

Posted by: T.Saravanan on: 9/15/2012 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi Mahesh,

Try the below link...
http://www.dotnetfunda.com/codes/code974-add-combobox-control-in-datagridview-column-and-get-its-selected-value.aspx

Thanks,
T.Saravanan

Mahesh_Chs, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/17/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
see this link
http://www.codeproject.com/Articles/31347/Creating-an-ASP-NET-GridView-Custom-Field-of-type

Thanks & Regards
Hari

Mahesh_Chs, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vikash on: 9/17/2012 [Member] Starter | Points: 25

Up
0
Down
PLease Use this...
define an event in drop down list like following
<asp:DropDownList ID="DropDownList1" runat="server"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>

and then access the value
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddl = (DropDownList)sender;
string str = ddl.SelectedValue;
}

if it is helpful mark as answer....

Regards,
Vikash Pathak

Mahesh_Chs, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rimi1289 on: 2/1/2013 [Member] Starter | Points: 25

Up
0
Down
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean

If keyData = Keys.Enter Then
If ActiveControl.Name = "ComboBox1" Then
ComboBox1.Visible = False

With DataGridView1
.Focus()
.Item(.CurrentCell.ColumnIndex, .CurrentRow.Index).Value = Trim(ComboBox1.Text)
.CurrentCell = .Rows(.CurrentRow.Index).Cells(.CurrentCell.ColumnIndex + 1)
End With
end if

end if


You can check the entire code here... http://www.encodedna.com/2013/02/show-combobox-datagridview.htm

Mahesh_Chs, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response