On 11 Mar 2007 13:22:37 -0700,
rn**@rediffmail .com wrote:
A DataGrid has a BoundColumn, an EditCommandColu mn & a few
TemplateColumns . When the text in the EditCommandColu mn within any of
the DataGridItems is clicked, the corresponding BoundColumn changes to
a TextBox.
How do I get the ID of such a TextBox?
You need to set the onRowCommand and retrieve the cell by its offset in the
row that is clicked
... See
http://www.thescripts.com/forum/thread454303.html
This is code from one of my gridviews
-snip---aspx---------
onRowCommand="s preadEditOnRowC ommand"
DataSourceID="S qlDataSource6"
ForeColor="Blac k"
GridLines="Vert ical"
Style="z-index: 101; left: 0px; position: absolute; top: 250px">
<FooterStyle BackColor="#CCC C99" />
<Columns>
<asp:ButtonFiel d ButtonType="But ton" CommandName="De tails" Text="Sync" />
<asp:BoundFie ld DataField="umen o" HeaderText="ume no" ReadOnly="True"
SortExpression= "umeno" />
<asp:BoundFie ld DataField="arti cleno" HeaderText="art icleno"
ReadOnly="True" SortExpression= "articleno" />
<asp:BoundFie ld DataField="spre adno" HeaderText="spr eadno"
ReadOnly="True" SortExpression= "spreadno" />
<asp:BoundFie ld DataField="desc ription" HeaderText="des cription"
SortExpression= "descriptio n" />
<asp:BoundFie ld DataField="spre adimage" HeaderText="spr eadimage"
SortExpression= "spreadimag e" />
</Columns>
-snap----aspx.cs--------
protected void spreadEditOnRow Command(object src, GridViewCommand EventArgs
e)
{
if (e.CommandName == "Details")
{
// get the row index stored in the CommandArgument property
int index = Convert.ToInt32 (e.CommandArgum ent);
// get the GridViewRow where the command is raised
GridViewRow selectedRow = ((GridView)e.Co mmandSource).Ro ws[index];
// get the spreadno
string spreadSpreadNo = selectedRow.Cel ls[3].Text;
// Store the spreadno
Session["spreadno"] = spreadSpreadNo;
}
}
--snop-----------
Mark