|
I first bind the datalist to the database. There are three columns: id, title, and time. Among them, title and time are displayed through two columns in the datalist. However, I do not want to display the id.
If I want to get the title or time column of the row when I click the button in the datalist, it is very simple. I do this
private void datalist_ItemCommand (object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
{
if (e.CommandName == "b")
{
lb.Text = ((System.Web.UI.WebControls.Label) e.Item.FindControl ("lb1")). Text;
}
}
Then I want to get the id of the row where I write it. I have bound the id column to the datalist, but there is no control key in the datalist to display this id. The main thing is that I cannot use the datakey because this has already been given Listed. Is there a general method, as long as the datalist or datagrid is bound, then you can get the value of any item in any row of datatalbe |
|