how to find textboxes and combobox in datagridview..??

Posted by Rock_Monu under C# on 8/22/2012 | Points: 10 | Views : 7373 | Status : [Member] | Replies : 3
How to find textboxes and combox in datagridview in windows form in asp.net and how to send multiple data in database from datagridview..???




Responses

Posted by: Ashok557 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down

To Find the Controls like TextBox,Combobox we use FindControl() method .so Use Find Control Method

Ex:

gridview.rows[e.rowindex].cells[<Your TextBox index>].FindControl("TextBox");
gridview.rows[e.rowindex].cells[<Your TextBox index>].FindControl("ComboBox");


N.ashokkumar

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

Posted by: Lalitha86 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down

HiddenField hdnDate = (HiddenField)row.FindControl("HiddenField1");
LinkButton linkdisplay = (LinkButton)row.FindControl("Linkbtn");

just like this

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

Posted by: Ashish.Shrma on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
In Case of you want to fill combobox along with grid fill function
write something like this at grid rowdatabound
Dim ddl As DropDownList = CType(e.Row.FindControl("ddlParameter"), DropDownList)

sql = "Select any data from table"
ddl.DataSource = fill data list
ddl.DataBind()

In case you just want to access values of drop down list in a already filled grid
for i=0 to grid1.rows.count
Dim ddl As DropDownList = CType(e.Row.FindControl("ddlParameter"), DropDownList)
label1.text = ddl.selecteditem.text 'something like this
next

or

Dim ddl As DropDownList =CType( grid1.selectedrow.FindControl("ddlParameter"), DropDownList)
label1.text=ddl.text


hope this will help

Ashish

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

Login to post response