This might be very basic question to some but I am struggling for quite some time.
I created an aspx page which has a search ability on User Table (Database). When Search button is cliked related Grid is filled with UserNames. And I put an Edit HyperLink in every row right next to UserName Column.
However Edit button should get a parameter named “UserCode” (this information also comes when I retrieved the names) but I just couldn’t write the appropriate code to the related line. Please in my codes there is a line contains I DONT KNOW WHAT TO TYPE IN HERE. Instead of index solution, any other suggestions are welcome.
DataTable oDataTable;
DataView oDataView;
protected void SearchLinkButton_Click(object sender, EventArgs e)
{
MembershipUserCollection allUsers = Membership.GetAllUsers();
if (allUsers != null)
{
oDataTable = new SystemUserAccountBsWrapper().SearchAllUsers(null); //Fetchs all user data
oDataView = oDataTable.DefaultView;
oDataView.Sort = "UserName";
oDataView.RowFilter = "UserName LIKE '%" + UserNameTextBox.Text + "%'";
UserGridView.DataSource = oDataView;
UserGridView.DataBind();
}
}
protected void UserGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink EditHyperLink = (HyperLink)e.Row.FindControl("EditHyperLink");
EditHyperLink.NavigateUrl("EditUserInfo.aspx?key=" + oDataTable.Rows[**I DONT KNOW WHAT TO TYPE IN HERE**]["UserCode"]);
}
}
Sorry for my bad English.
DataBinder.Eval can be used on codebehind also