Click here to Skip to main content
15,890,579 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Button in Master Page Validates content section textboxes,How to avoid Pin
reogeo200831-Dec-08 18:41
reogeo200831-Dec-08 18:41 
GeneralRe: Button in Master Page Validates content section textboxes,How to avoid Pin
Christian Graus1-Jan-09 2:31
protectorChristian Graus1-Jan-09 2:31 
AnswerRe: Button in Master Page Validates content section textboxes,How to avoid Pin
sepel31-Dec-08 20:12
sepel31-Dec-08 20:12 
QuestionSending email from website Pin
CrimeanTurtle200831-Dec-08 17:37
CrimeanTurtle200831-Dec-08 17:37 
AnswerRe: Sending email from website Pin
Christian Graus31-Dec-08 17:50
protectorChristian Graus31-Dec-08 17:50 
GeneralRe: Sending email from website Pin
CrimeanTurtle200831-Dec-08 18:11
CrimeanTurtle200831-Dec-08 18:11 
GeneralRe: Sending email from website Pin
Christian Graus1-Jan-09 2:31
protectorChristian Graus1-Jan-09 2:31 
Questiondynamically adding buttonfields to gridview Pin
g00fyman31-Dec-08 15:25
g00fyman31-Dec-08 15:25 
Hi all, Happy New Year Smile | :)

Can someone please help me with the following scenario. I do not like how the default setting is to have the select and delete button together in a grid view row so I am extending gridview (for other reasons) and am dynamically adding my own fields, select at 0, delete at columns.count - 1.

Whenever I add OnClientClick code to the delete button the button is just posting back and not firing a delete command.

protected override void OnInit(EventArgs e)
    {
      base.OnInit(e);

      ButtonField select = new ButtonField();
      select.CommandName = "Select";
      select.ButtonType = ButtonType.Image;
      select.ImageUrl = Page.ClientScript.GetWebResourceUrl(GetType(), EDIT_ICON);
      Columns.Insert(0, select);

      ButtonField delete = new ButtonField();
      delete.CommandName = "Delete";
      delete.ButtonType = ButtonType.Image;
      delete.ImageUrl = Page.ClientScript.GetWebResourceUrl(GetType(), DELETE_ICON);
      Columns.Add(delete);
    }

    protected override void OnPreRender(EventArgs e)
    {
      base.OnPreRender(e);
      
      if (Page.IsPostBack == false)
      {
        foreach (GridViewRow row in Rows)
        {
          if (row.RowType == DataControlRowType.DataRow)
          {
            ImageButton select = row.Cells[0].Controls[0] as ImageButton;
            select.ToolTip = "Modify";
            select.AlternateText = "Modify";
            select.CssClass = "select-button";

            ImageButton delete = row.Cells[row.Cells.Count - 1].Controls[0] as ImageButton;
            // the following line causes button to not fire a delete command
            //delete.OnClientClick = "return confirm('Are you sure you want to delete this item?\\n\\nClick OK to delete this item or Cancel to keep it.');";
            delete.ToolTip = "Delete";
            delete.AlternateText = "Delete";
            delete.CssClass = "delete-button";
          }
        }
      }
    }



Thanks,
Maurice
AnswerRe: dynamically adding buttonfields to gridview Pin
g00fyman31-Dec-08 15:50
g00fyman31-Dec-08 15:50 
GeneralRe: dynamically adding buttonfields to gridview Pin
g00fyman31-Dec-08 16:40
g00fyman31-Dec-08 16:40 
Questionpublishing pages using FTB program. Pin
ahlamasp31-Dec-08 7:18
ahlamasp31-Dec-08 7:18 
AnswerRe: publishing pages using FTB program. Pin
Not Active31-Dec-08 9:12
mentorNot Active31-Dec-08 9:12 
AnswerRe: publishing pages using FTB program. Pin
Christian Graus31-Dec-08 17:13
protectorChristian Graus31-Dec-08 17:13 
GeneralRe: publishing pages using FTB program. Pin
ahlamasp1-Jan-09 5:09
ahlamasp1-Jan-09 5:09 
QuestionPrecreated column in inherited gridview Pin
Member 202259231-Dec-08 6:39
Member 202259231-Dec-08 6:39 
QuestionEmail exist or not. Pin
kavitha_blueindia31-Dec-08 6:15
kavitha_blueindia31-Dec-08 6:15 
AnswerRe: Email exist or not. Pin
scottgp31-Dec-08 6:48
professionalscottgp31-Dec-08 6:48 
AnswerRe: Email exist or not. Pin
Christian Graus31-Dec-08 17:11
protectorChristian Graus31-Dec-08 17:11 
QuestionI want to create option like print and mail to friend in my site same as codeproject Pin
cooolguymca31-Dec-08 2:56
cooolguymca31-Dec-08 2:56 
AnswerRe: I want to create option like print and mail to friend in my site same as codeproject Pin
N a v a n e e t h31-Dec-08 3:01
N a v a n e e t h31-Dec-08 3:01 
AnswerRe: I want to create option like print and mail to friend in my site same as codeproject Pin
Aman Bhullar31-Dec-08 6:02
Aman Bhullar31-Dec-08 6:02 
QuestionHow to use FileUpload Pin
Muhammad Gouda31-Dec-08 2:17
Muhammad Gouda31-Dec-08 2:17 
AnswerRe: How to use FileUpload Pin
N a v a n e e t h31-Dec-08 2:52
N a v a n e e t h31-Dec-08 2:52 
GeneralRe: How to use FileUpload Pin
Abhijit Jana31-Dec-08 2:56
professionalAbhijit Jana31-Dec-08 2:56 
GeneralRe: How to use FileUpload Pin
N a v a n e e t h31-Dec-08 2:59
N a v a n e e t h31-Dec-08 2:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.