views:

42

answers:

1

Hi all,

i am having a problem with my asp project C#

i have a GridView that is created dynamically and each cell contains a buttonfield with link button type

i just wanna return back the text of the buttonfield when i clicked it

The problem actually in indicating the selected cell that i clicked

i could get the value of selected row but not selected cell

Can anyone help me with that?

A: 

protected void gridviewRowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Click") { e.CommandArgument<-- bind the text you wanna get

}

}

================= CommandName="Click" CommandArgument='<%# Eval("buttonfield values") %>'

or u can find the row in the grid index and the use

btnfield = gridview.rows[rowIndex].findControl("buttonfieldName") as buttonfield

pjb
to get the row index click u need in grid--- CommandArgument='<%# Container.DataItemIndex %>'
pjb
This is exactly what i am doing but the e.CommandArgument returns the index of the row what i need is the index of column or cell This is my code:if (e.CommandName == "click") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = v.Rows[index]; string lastname = ((LinkButton)selectedRow.Cells[0].Controls[0]).Text.ToString(); Session["name"] = lastname; Server.Transfer("~/change_shifts.aspx"); }But the problem is i don't wanna the value of cell[0]. i want the value of the cell i clicked
Aya
find the control once u have the row...so did this work?.btnfield = gridview.rows[rowIndex].findControl("buttonfieldID") as buttonfield;string lastname = btnfield .text,If this doesnt work paste ur html code.
pjb