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

radgrid editmode/initmode default based query parameter

4 Answers 125 Views
Grid
This is a migrated thread and some comments may be shown as answers.
nanthakumar thangavel
Top achievements
Rank 1
nanthakumar thangavel asked on 06 Jun 2011, 02:08 PM
HI
if i ll pass query parameter (?Id=0) value is 0 radgrid should be  opened  initinsertmode by defult orelse query  parameter (?id=10) is 10 or any value ,radgrid should be opened Correct index item in editmode by default .its all should be done in page load event.

what can i do for this?if u send me a sample application for this, it ll be very helpful to me.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Jun 2011, 02:48 PM
Hello,

Try the following code snippet to achieve your requirement.
C#:
protected void Page_Load(object sender, EventArgs e)
    {
 
      int value = Convert.ToInt16(Request.QueryString["Index"]);
      if(value==0)
        {
        RadGrid1.MasterTableView.IsItemInserted = true;
        }
      else
        {
            RadGrid1.EditIndexes.Add(value);
        }       
    }

Thanks,
Princy.
0
nanthakumar thangavel
Top achievements
Rank 1
answered on 06 Jun 2011, 03:02 PM
Hi Princy,

Thanks for  your fast reply 

But i ll pass only  DataKeyNames value as parameter instead of index.how can i find out  the item index based on DatakeyName value



0
Jayesh Goyani
Top achievements
Rank 2
answered on 06 Jun 2011, 05:33 PM
hi,

int valueID= Convert.ToInt32(Request.QueryString["ID"]);
      if(valueID==0)
        {
        RadGrid1.MasterTableView.IsItemInserted = true;
        }
      else
        {
            foreach (GridDataItem item in RadGrid1.Items)
    {
              if(Convert.ToInt32(item.GetDataKeyValue("ID")) == valueID ) // Where DataKeyName = "ID"
        {
            item.Edit = true;
        }
    }
        
 
RadGrid1.Rebind();

if u get any error related to edittable then used below link.

http://www.telerik.com/help/aspnet/grid/grddefaulteditmodeforgriditemsoninitialload.html

Thanks,
Jayesh Goyani
0
nanthakumar thangavel
Top achievements
Rank 1
answered on 07 Jun 2011, 07:19 AM
Hi,
Thanks for your reply .

 if I ll bind 500 rows to rad-grid with set property allowpaging is true ,after that I pass the 2nd page DataKeyName value as a parameter.  but I can not retrieve the 2nd page DataKeyName item index.

what can i do for this problem?

this is  my code 

Private Sub GRD_NewsList_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles GRD_NewsList.PreRender
        If Not Page.IsPostBack Then
            Dim val As String = GetNumeric(Request("NewsId"))
            If val = 0 Then
                GRD_NewsList.MasterTableView.IsItemInserted = True
            Else
                For Each Items As GridDataItem In GRD_NewsList.MasterTableView.Items
 
                    If GetNumeric(Items.GetDataKeyValue("NewsId")) = val Then
                        Items.Edit = True
                        Exit For
                    End If
                Next
            End If
            GRD_NewsList.Rebind()
        End If
    End Sub

Tags
Grid
Asked by
nanthakumar thangavel
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
nanthakumar thangavel
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Share this question
or