<asp:TemplateField> <ItemTemplate> <asp:Button ID="ButtonEdit" runat="server" Text="Edit" causesvalidation = "false" OnCommand="EditDetails" CommandArgument='<%# Eval("TableID").ToString() %>' CommandName="ButtonCommandEdit" /> </ItemTemplate> </asp:TemplateField>
string recordID = ""; //to be used in *** protected void EditDetails(object sender, CommandEventArgs e) { recordID = e.CommandArgument.ToString(); //to set value of *** GridViewUserInfoTable.Enabled = false; ButtonUpdate.Visible = true; ButtonCancel.Visible = true; ButtonSubmit.Visible = false; var connectionString = "server=localhost;uid=root;" + "pwd=xxxxx;database=xxxxx;"; using (var connection = new MySqlConnection(connectionString)) { connection.Open(); var query = "select * from table where tableID= " + recordID; //using the value of *** using (var command = new MySqlCommand(query, connection)) { using (var reader = command.ExecuteReader()) { while (reader.Read()) { TextBoxfirstName.Text = (reader.GetString("firstName")); TextBoxmiddleName.Text = (reader.GetString("middleName")); TextBoxlastName.Text = (reader.GetString("lastName")); TextBoxmobileNo.Text = (reader.GetString("mobileNo")); TextBoxemailAddress.Text = (reader.GetString("emailAddress")); TextBoxregistrationDate.Text = reader.GetDateTime("registrationDate").ToString("yyyy-MM-dd"); TextBoxstreet.Text = (reader.GetString("street")); DropDownListCity.SelectedValue = (reader.GetString("city")); //i believe i need to change something here in DropDownLists DropDownListRegion.SelectedValue = (reader.GetString("region")); TextBoxcountry.Text = (reader.GetString("country")); } } } } if (Page.IsPostBack) { //nothing } }
DropDownListCity.SelectedItem.Text = (reader.GetString("city"));
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)