ASP.NET - Check box in Telerik Radgrid control

Asked By sushma on 02-Aug-11 02:24 AM
Hi All,

I have a delete button outside the radgrid control when i check the checkboxes in the radgrid, using the delete button i shoul delete the checkboxes, can any one send the code for this problem.
Jitendra Faye replied to sushma on 02-Aug-11 02:27 AM
You can hide the CheckBox of RadGrid,

Use this code-

protected void BtnHide_Click(object sender, EventArgs e)
  {
    foreach (GridViewRow row in GridView1.Rows)
    {
    ChecvkBox ckh= (CheckBox)row.FindControl("checkBox1");
    if(chk!=null)
     {
        chk.Visible=false;
      }
      }
   }

Hope this will help you.
Asked By sushma on 02-Aug-11 02:29 AM
Hi ,

I have written code like this, can you modify this please,,,,,,,,,,,
protected void btnDelete_click(object sender, EventArgs e)
      {          
       string strstudhstprint = string.Empty;            
       ScheduleStatusDO objschedulestatus = new ScheduleStatusDO();
       objschedulestatus.StudentHistoryPrintID = 0;
        foreach (GridDataItem row in rgScheduleStatus.Items)
        {                   
          if (row.ItemType == GridItemType.Item)
          {
            CheckBox deletechkbox = (CheckBox)row.FindControl("chkschedulestatus");
            if (deletechkbox.Checked)          
            {
              int intstudhstprnt = Convert.ToInt32(row.OwnerTableView.DataKeyNames);
              strstudhstprint += intstudhstprnt + ",";                         
            }
          }
          else if (row.ItemType == GridItemType.Header)
          {
            CheckBox deletechkbox = (CheckBox)row.FindControl("chkSelectall");
            if (deletechkbox.Checked)
            {
              int intstudhstprnt = Convert.ToInt32(row.Cells[7].Text);
              strstudhstprint += intstudhstprnt + ",";
            }

          }
        }
        ScheduleStatusUI Deletebox = new ScheduleStatusUI();
        Button btn = new Button();     
        btn.FindControl("btndelete");
        btn.Attributes.Add("OnClick", "DeleteConfirmation('" + Deletebox.DeleteScheduleStatusUI(objschedulestatus.StudentHistoryPrintID) + "'strstudhstprint'" +  "')");
      }           
    }
Reena Jain replied to sushma on 02-Aug-11 02:31 AM
hi,

here is code for you, by this you can delete more than on row from datagridview as well from database

01.private void button1_Click(object sender, EventArgs e)
02.{  
03.  System.Collections.ArrayList alv = new System.Collections.ArrayList();
04.  int i = 0;
05.  private void button1_Click(object sender, EventArgs e)
06.  {
07.  OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<<Your Database Path>>");
08.  OleDbCommand cmd=new OleDbCommand();
09.  for (int i = 0; i < RedGridView1.Rows.Count; i++)
10.  {
11.    RedGridViewRow MyRow = RedGridView1.Rows[i];
12.  if (MyRow.Selected == true)
13.  {
14.    RedGridView1.Rows.RemoveAt(i);
15.  try
16.  {
17.    conn.Open();
18.    //Here It Will Delete your Row From The Database Depending On Your Id....
19.    cmd.CommandText = "DELETE FROM MyTable Where Id=" + i + "";
20.    cmd.ExecuteNonQuery();
21.    conn.Close();
22.  }
23.  catch(Exception ex)
24.  {
25.    MessageBox.Show(ex.ToString());
26.  }
27.  }
28.  }
29.  }
30.}

hope this will help you
sushma replied to Reena Jain on 02-Aug-11 02:34 AM
Hi,

I am using the procedure in dataaccess from there i am calling that function to presentation layer i.e aspx.cs page how can i do using my code?
Asked By sushma on 02-Aug-11 02:38 AM
Hi,
 Iam getting Input string is not in correct format error at this place of code
 int intstudhstprnt = Convert.ToInt32(row.OwnerTableView.DataKeyNames); I didnt understand this error so please can u solve this error.
Asked By sushma on 02-Aug-11 03:31 AM
Hi All,

I have telerik radgrid contains the checkboxes in header part also, i want to check and uncheck the checkboxes. if check the header thn it should check all the checkboxes and if uncheck 1 checkbox also it should uncheck the header checkbox. how can i write the code for this in javascript, and i should call the javascrpit at server side. can any 1 send the code for this, here is the code of radgrid

 <telerik:GridTemplateColumn HeaderText="Delete" HeaderStyle-CssClass="tal la" ItemStyle-CssClass="tal la" UniqueName="chkschedulestatus">
         <HeaderTemplate>
           <asp:CheckBox runat="server" ID="chkSelectall"  Text="Delete" CssClass="chkheader"/>           
         </HeaderTemplate>
          <ItemTemplate>        
          <asp:HiddenField runat="server" ID="hdnStudentHistoryPrintID" />
          <asp:CheckBox runat="server" ID="chkSelect"/>
         </ItemTemplate>              
       </telerik:GridTemplateColumn>