0
<asp:TemplateField HeaderText="ID" SortExpression="CareerFormID">
<ItemTemplate>
<asp:Label ID="CareerFormID" runat="server" Text='<%#Eval("CareerFormID")%>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Checked" DataField="checked" />
<asp:ButtonField Text="Edit" CommandName="Select" ButtonType="Link" />
protected void OnSelectedIndexChanged(object sender, EventArgs e)
{
string idtemp = (GridView1.SelectedRow.FindControl("CareerFormID") as Label).Text;
Session["CompanyFormID"] = idtemp;
Response.Redirect("Management_Edit.aspx");
//Response.Write(Session["CompanyFormID"]);
}
當DataField =「checked」爲1時,我想更改ButtonField text =「Modify」,我該怎麼做?如何更改asp.net中的ButtonField文本
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[4].Text == "1")
{
e.Row.Cells[4].Text = "Yes";
e.Row.Cells[4].ForeColor = System.Drawing.Color.Green;
e.Row.Cells[6].Text = "Modify";
}
else if (e.Row.Cells[4].Text == "0")
{
e.Row.Cells[4].Text = "No";
e.Row.Cells[4].ForeColor = System.Drawing.Color.Red;
}
}
}
但這不起作用,單元格[6]文本被更改,但鏈接被取消。
對於這樣的例子,當我更改文本
http://i.imgur.com/CN5snv6.jpg