Groups | Blog | Home
all groups > asp.net datagrid control > october 2003 >

asp.net datagrid control : vb to C# converstion question



]-[aTc]-[
10/13/2003 12:27:20 PM
Hello.
In the book "ASP.NET Data Web Controls" page 259 in VB it shows
Dim nameTextBox as TextBox = e.Item.Cells(2).Controlls(0)

How do I convert that to C#.
I have
TextBox CompanyName = e.Item.Cells[3].Controls[0];

and I get an error of "Cannot implicity convert type 'System.Web.UI.Control'
to 'System.Web.UI.WebControls.TextBox"

How do I make this work.

Thanks

--Mike

bspann
10/13/2003 3:15:35 PM
Mike,

You need to cast. Here is what the code should look like:

TextBox CompanyName = (TextBox)e.Item.Cells[3].Controls[0];

Try that, it should work.

Brian

[quoted text, click to view]

AddThis Social Bookmark Button