Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 11, 2013 10:51 AM by oned_gk
Jan 10, 2013 10:47 AM|LINK
I do have a Problem concernig TemplateFields in a Gridview Control.
As EditItem Control I use a Dropdown Field. Depending on the Value of the Dropdown I´d like to change the Backround Colour of another Cell in the same Row.
At first I set the Row in Edit mode. Then I change the Value of the Dropdown an leave the Edit-Mode. I´ve tried several Events to start the change of the colour. For example the RowUpdating Event. But it alway occurs the same error. "NullReferenceExeption".
This is my code:
Dim aDropdown As New DropDownList
Dim aValue As String
aDropdown = GridView1.Rows(1).Cells(3).FindControl("DropDownList1")
aValue = aDropdown.Text
In Debug Mode aDropdown.Text shows the correct Value. I don´t understand what causes this error.
Can anyone of you please help me out? Thanks a lot in advance for your help!
Jan 10, 2013 10:54 AM|LINK
Jan 11, 2013 09:52 AM|LINK
Thanks alot. This Works. But I still have a Problem with the colours of the raws. At wich point can I change the colours of the gridview after editing a row? In the beginning I use the Page_load Event to change the colours. But after editing a row this event
doesn´t work anymore. Which is the correct event to choose?
Thanks a lot in advance for your answers and have a nice Weekend!
Jan 11, 2013 10:51 AM|LINK
Change the color using rowdatabound event
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)