Click here to Skip to main content
15,913,610 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionGrid View Question Pin
Mavericks523-Jul-07 5:09
Mavericks523-Jul-07 5:09 
AnswerRe: Grid View Question Pin
Mavericks523-Jul-07 5:57
Mavericks523-Jul-07 5:57 
GeneralRe: Grid View Question Pin
Not Active23-Jul-07 8:25
mentorNot Active23-Jul-07 8:25 
AnswerRe: Grid View Question Pin
kubben23-Jul-07 7:11
kubben23-Jul-07 7:11 
GeneralRe: Grid View Question Pin
Mavericks523-Jul-07 7:18
Mavericks523-Jul-07 7:18 
GeneralRe: Grid View Question Pin
kubben23-Jul-07 7:42
kubben23-Jul-07 7:42 
GeneralRe: Grid View Question Pin
Mavericks523-Jul-07 7:58
Mavericks523-Jul-07 7:58 
GeneralRe: Grid View Question Pin
kubben23-Jul-07 8:08
kubben23-Jul-07 8:08 
For the delete button outside of the grid view here is the code I am using:
NOTE in all my gridviews I have the first column in the gridview be a template column that has a label that contains the database table unique id. I mark this label as not visible, so it doesn't show up on the web page, but it is in the code behind, so I know what datarow I am dealing with.

protected void lBtnDeleteList_Click(object sender, EventArgs e)
{
 if (SomethingChecked() == 0)
 {
  this.custValidatorSendtoEmail.ErrorMessage = "Please check a list to delete.";
  this.custValidatorSendtoEmail.IsValid = false;
  return;
 }

 GridViewRow gvr = null;
 Label listID = null;
 for (int i = 0; i < this.GridView1.Rows.Count; i++)
 {
  gvr = this.GridView1.Rows[i];
  if (((CheckBox)gvr.FindControl("chkBoxSelect")).Checked)
  {
   listID = (Label)gvr.FindControl("lbListID");
   this.ObjectDataSource1.DeleteParameters["ListID"].DefaultValue = listID.Text;

   //Note we have set up a delete method in the object data source to take in the    
   //listid and delete that list.
   this.GridView1.DeleteRow(i);
  }
 }
}

private int SomethingChecked()
{
  int ret = 0;
  foreach (GridViewRow gvr in this.GridView1.Rows)
  {
   if (((CheckBox)gvr.FindControl("chkBoxSelect")).Checked)
   {
    ret += 1;
   }
  }//foreach
 return ret;
}


Hope that helps.
Ben
GeneralRe: Grid View Question Pin
Mavericks523-Jul-07 8:25
Mavericks523-Jul-07 8:25 
GeneralRe: Grid View Question Pin
kubben23-Jul-07 8:27
kubben23-Jul-07 8:27 
GeneralRe: Grid View Question Pin
Mavericks523-Jul-07 8:28
Mavericks523-Jul-07 8:28 
GeneralRe: Grid View Question Pin
kubben23-Jul-07 8:28
kubben23-Jul-07 8:28 
GeneralRe: Grid View Question Pin
Mavericks523-Jul-07 8:51
Mavericks523-Jul-07 8:51 
GeneralRe: Grid View Question Pin
Mavericks523-Jul-07 8:26
Mavericks523-Jul-07 8:26 
GeneralRe: Grid View Question Pin
Mavericks523-Jul-07 8:27
Mavericks523-Jul-07 8:27 
GeneralRe: Grid View Question Pin
kubben23-Jul-07 8:32
kubben23-Jul-07 8:32 
GeneralRe: Grid View Question Pin
Mavericks523-Jul-07 8:52
Mavericks523-Jul-07 8:52 
GeneralRe: Grid View Question Pin
kubben23-Jul-07 9:01
kubben23-Jul-07 9:01 
GeneralRe: Grid View Question Pin
Mavericks523-Jul-07 10:00
Mavericks523-Jul-07 10:00 
GeneralRe: Grid View Question Pin
kubben23-Jul-07 12:06
kubben23-Jul-07 12:06 
GeneralRe: Grid View Question Pin
Mavericks523-Jul-07 12:07
Mavericks523-Jul-07 12:07 
GeneralRe: Grid View Question Pin
kubben24-Jul-07 1:10
kubben24-Jul-07 1:10 
QuestionSorting Data of Data Grid Control Pin
Khan.Bangash23-Jul-07 4:50
Khan.Bangash23-Jul-07 4:50 
AnswerRe: Sorting Data of Data Grid Control Pin
jcdevnet23-Jul-07 5:34
jcdevnet23-Jul-07 5:34 
AnswerRe: Sorting Data of Data Grid Control Pin
sathesh pandian23-Jul-07 5:35
sathesh pandian23-Jul-07 5:35 

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.