Excuse a newby's etiquette, I just posted this question as a comment in a previously answered question and am afraid that no one will see it and respond.
I have a DataGrid in which I set some of the columns as bound fields from a datasource. There are several columns, not bound, that I want to either allow the user to enter, or to get the data from other sources and fill in arbitrarily. It is no problem having the user enter the data and retrieving what they have entered.
In the example below, I have omitted all the fields except the one I am trying to manipulate. What I want to do is update the contents of the cell in the DataGrid, not access the contents.
Here is my DataGrid:
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1"
AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333"
<RowStyle BackColor="#E3EAEB" />
<asp:TemplateField HeaderText="First Name">
<asp:TextBox ID="tbxFname" runat="server"></asp:TextBox>
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#7C6F57" />
<AlternatingRowStyle BackColor="White" />
In the code behind I want to put text into the tbxFname textbox of the template field. I cannot find the correct construct to do this. I can easily get the contents of it, but actually modifying its contents is eluding me.
GridView1.Rows[index].Cells.Controls.Text = "some string";
is wrong - .Text is not a valid property. I have tried many other combinations of attributes with no success. Any help?