Problem:
The first column of the gridview is buttonfield, and the field name is "delete". If you want to delete it, a confirmation box is displayed. Otherwise, how should I write the result?
Solution:
1. Click the shortcut arrow of the gridview and select 'edit column '.
2. Add a buttonfiled, set headtext (for display) in the property box on the right, and define a commandname (for the action triggered after you click)
3. Click 'convert to template columns 'in the lower right corner. OK.
4. Right-click the gridview, 'edit template' -- 'column [..] -- your previously defined headtext'. Can you see your button in itemtemplate? Point, there is an item 'onclientclick' in the property, put "javascript: Return confirm ('Do you really want to delete it? '); "Paste in.
5. Complete the functions you need.
6. If you want to click the button to trigger other events, you can write in detail in the rowcommand event...
Protected void gridview1_rowcommand (Object sender, gridviewcommandeventargs E)
{
If (E. commandname = "mybtnclicked") // The commandname you defined earlier
{
Response. Write ("kkk clicked ");
}
}
1. In Step 4 above, you can see the small arrow in the upper right corner of your button in itemtemplate. verygood, click 'edit databings '...
2. Have you seen the binding at this level? Bind commandargument to the field you want to operate... (Select from the drop-down list on the right)
3. OK. Now you can call the following method:
------------------
Protected void gridview1_rowcommand (Object sender, gridviewcommandeventargs E)
{
If (E. commandname = "mybtnclicked ")
{
Response. Write ("You Wanted" + E. commandargument. tostring ());
}
}
------------------
You just want to get the content in the cell in the result set. Now you want to bind the content to the commandargument, so you don't need to index any cell []. text (you need findcontrol for complicated cells, huh, huh)