This is a migrated thread and some comments may be shown as answers.

Help me urgenntly need for my project

9 Answers 165 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Velmurugan
Top achievements
Rank 1
Velmurugan asked on 11 Oct 2011, 11:24 AM
hi,,,,

          i am velmurugan from chennai.

                                            i need a selecting all checkbox  column in radgrid when i click the header checkbox selecting all checkbox
i have attached link example.this is using one column in  gridview but i need 5 columns(ADD,EDIT,DELETE,NONE,VIEW)using radgridview
http://www.codeproject.com/KB/webforms/SelectingAllCheckBoxes.aspx

help me,,,,

THANKZ....

9 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Oct 2011, 12:16 PM
Hello VelMurugan,

Here is an online demo which demonstrates the desired functionality.
Grid / Server-Side Row Selection

Thanks,
Shinu.
0
Velmurugan
Top achievements
Rank 1
answered on 13 Oct 2011, 05:36 AM
hi,,,,  not like that ..
        just see that above link after u will give some ideas for me
0
Shinu
Top achievements
Rank 2
answered on 13 Oct 2011, 09:28 AM
Hello Velmurugan,

The functionalities in both links are same. When you are clicking the header checkbox it will select all the checkboxes in RadGrid rows. Hope it clear now.

Please elaborate your scenario if it doesn't help.

Thanks,
Shinu.
0
Velmurugan
Top achievements
Rank 1
answered on 31 Oct 2011, 11:44 AM
hi.....

     i have  select all items from listbox using SelectionMode="Multiple"  but how to store all items in database like item1,item2,item3 and radgrid like  item1,item2,item3

anyone help me..
thanks in advance..
0
Princy
Top achievements
Rank 2
answered on 31 Oct 2011, 01:59 PM
Hello Velmurugan,

You can try the following code snippet to insert the SelectedItems of ListBox in a DataBase table. Once the table is populated you can use this as the table for RadGrid.

C#:
protected void btn_Click(object sender, EventArgs e)
{
 SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ToString());
 string arr=null;
 int s = RadListBox2.SelectedItems.Count;
 for (int i = 0; i < s; i++)
 {
  arr += RadListBox2.Items[i].Text + ",";
 }
   int index = arr.LastIndexOf(',');
   arr = arr.Remove(index , 1);
   string t = "insert into list1  values('" + arr + "')";
   con.Open();
   SqlCommand cmd=new SqlCommand(t,con);
   cmd.ExecuteNonQuery();
   con.Close();
}

Thanks,
Princy.
0
Velmurugan
Top achievements
Rank 1
answered on 02 Nov 2011, 08:25 AM
hi princy,
             thanq for your reply, but i am using in insert command...and my code is..

 <telerik:GridTemplateColumn HeaderText="PERIOD" UniqueName="PERIOD" DataField="PERIOD" >
                         <ItemTemplate>
                              <%#Eval("PERIOD")%>
                         </ItemTemplate>
                        <EditItemTemplate>
                               <telerik:RadListBox ID="listbox" runat="server" SelectionMode="Multiple" DataSourceID="sqlDataSource5" DataTextField="PERIOD" DataValueField="PERIOD"></telerik:RadListBox>
                         </EditItemTemplate>
                </telerik:GridTemplateColumn>


          protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)
    {
        GridDataInsertItem insertitem = (GridDataInsertItem)e.Item;
        RadListBox list = (insertitem["PERIOD"].FindControl("listbox")) as RadListBox;
            string arr=null;
            for (int i = 0; i < list.Items.Count; i++)
            {
                if (list.Items[i].Selected=true )
                {
                    arr = list.Items[i].Text +",";
                    string t = "insert into t_name  values('" + arr + "')";
                    SqlCommand.CommandText = t;
                    SqlCommand.Connection = SqlConnection;
                    SqlConnection.Open();
                    SqlCommand.ExecuteNonQuery();
                    SqlConnection.Close();
                }    } }

my output is displayed one by one.
plz help me.
0
Princy
Top achievements
Rank 2
answered on 02 Nov 2011, 08:42 AM
Hello  Velmurugan,

The code I gave worked as expected which stores the values as comma separated in DataBase. The DataType which I used is varchar.
Please elaborate your scenario if it doesn't help.

Thanks,
Princy.
0
Velmurugan
Top achievements
Rank 1
answered on 23 Nov 2011, 11:15 AM
hi princy,


           how to get seleted items in itemdatabound when edit mode

thanx in adv......
0
Princy
Top achievements
Rank 2
answered on 23 Nov 2011, 12:14 PM
Hello,

I suppose you want to set the value of ListBox in ItemDataBound when in edit mode.
CS:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
   {
      GridDataItem it = (GridDataItem)e.Item;
      Session["updatedValue"] = ((DataRowView)e.Item.DataItem)["EmployeeID"].ToString();
   }
  if ((e.Item is GridEditableItem && ((GridEditableItem)e.Item).IsInEditMode))
   {
      GridEditableItem edititem = (GridEditableItem)e.Item;
      RadListBox lst = (RadListBox)e.Item.FindControl("lst");
      lst.SelectedValue = (string)Session["updatedValue"];
   }
}

Thanks,
Princy.
Tags
General Discussions
Asked by
Velmurugan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Velmurugan
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or