I. <asp: LinkButton ID = "LinkButton1" runat = "server" CommandName = "updateState" Text = "available"
CommandArgument = '<% # Eval ("Roleid") %>'/>
Protected void GVrole_RowCommand (object sender, GridViewCommandEventArgs e)
{
If (e. CommandName = "updateState ")
{
LinkButton Lb = (LinkButton) sender;
Lb. Text = "disabled ";
}}
LinkButton can trigger CommandName, Button, imgeButon cannot trigger
Ii. <asp: ButtonField CommandName = "ShowTeam" HeaderText = "Team Info"
Text = "Team Info"/>
Protected void GVrole_RowCommand (object sender, GridViewCommandEventArgs e)
{
If (e. CommandName = "updateState ")
{
Page. Alert ("updateState ");
}
If (e. CommandName = "ShowTeam ")
{
Page. Alert (e. CommandArgument. ToString (); // e. CommandArgument obtains the index of the current row.
Int ClientID = Convert. ToInt32 (ClientGridview. DataKeys [index]. Value. ToString ());
Obtain the corresponding data
(LinkButton) e. CommandSource). Text = "disabled"; e. CommandSource obtains the event source, that is, LinkButton, And you can operate on the attributes of this linkButton}
}
Protected void GVrole_RowCommand (object sender, GridViewCommandEventArgs e)
{
If (e. CommandName = "updateState ")
If (LinkButton) e. CommandSource). Text. ToString () = "disabled ")
{
(LinkButton) e. CommandSource). Text = "available ";
}
Else
3. Configure the event using the onCommand command
<Asp: Button ID = "garbage" OnCommand = "garbage" OnClientClick = "return confirm ('Are you sure you want to set it to spam? '); "Runat =" server "Text =" spam "visible =" false "CommandName =" garbage "CommandArgument =' <% # Eval (" ID ") %> '/>
Protected void Refer (object sender, CommandEventArgs e)
{
Int id = Convert. ToInt32 (e. CommandArgument );
Using (DataClassesDataContext db = new DataClassesDataContext ())
{
Var QuSupport = db. QuestionSupport. FirstOrDefault (q => q. ID = id );
If (QuSupport! = Null)
{
Content. Text = QuSupport. SupportContent; // get Content
QuSupport. IsRefereed = true; // set the reference to true.
Try
{
Db. SubmitChanges ();
}
Catch (Exception)
{
Throw;
}
}
}
}