Click here to Skip to main content
15,911,707 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,


Help me to find out the value of dropdown in the row updating event of Grid.That drop down is added during row edit in the Row data bound event.

I have also tried adding the same control and binded same datasource in Row created event also.But i could not do the update.

((DropDownList)gvTest.Rows[e.RowIndex].FindControl("ddl")); value comes as null and throw instance of object not set to its reference error.



Please Help

Thanks
Siva
Posted

1 solution

in the event do
C#
GridViewRow gRow = GriwViewRow(sender);
GridView grid = (GridView)gRow.NamingContainer;
grid.SelectedIndex = gRow.RowIndex;

Now you can do a gRow.FindControl("").
at the end do
C#
grid.SelectedIndex = -1;
 
Share this answer
 
Comments
siva0001 14-Mar-12 1:05am    
I tried to use the above code in row Updating event but GridViewRow(sender) is throwing error.Should i modify anything there?
Herman<T>.Instance 14-Mar-12 4:40am    
can it be e.Row ? so GridViewRow gRow = = e.Row;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900