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

Bind controls in EditItemTemplate

13 Answers 336 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JSON
Top achievements
Rank 1
JSON asked on 05 Jul 2011, 01:05 PM
I have controls in an HTML Table inside an EditItemTemplate of a RADGRID parent control that I need to bind to. I have attempted to bind to the grid and to individual controls unsuccessfully.

13 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Jul 2011, 02:44 PM
Hello Json,

There are three ways to bind the grid to a database.


Thanks,
Princy.
0
JSON
Top achievements
Rank 1
answered on 05 Jul 2011, 05:47 PM
Does this imply that I cannot populate the dataasoucre via a stored proc as my example showed?
0
JSON
Top achievements
Rank 1
answered on 05 Jul 2011, 07:42 PM
Now I get the following:

unable to cast type 'system.web.ui.radgrid' to 'system.web.ui.radgrid'
0
Princy
Top achievements
Rank 2
answered on 06 Jul 2011, 06:37 AM
Hello Json,

I am not quite sure about the requirement. Please refer to this online demo for an live example of how to bind RadGrid to a DataReader instance.

Thanks,
Princy.
0
shrujan
Top achievements
Rank 1
answered on 06 Jul 2011, 10:36 AM
had a problem with radgrid.
I have added a radgrid  and i can edit and update the data in the radgrid followed by the link buttons.
but im unable to add a new row by clicking a link button in rad grid..
the problem is when ever i click on 'new' linkbutton the previous data gets disabled
0
Shinu
Top achievements
Rank 2
answered on 06 Jul 2011, 11:04 AM
Hello Shrujan,

Have you set the command name property to the link button correctly?

aspx:
<CommandItemTemplate>
      <asp:LinkButton runat="server" ID="AddNew" Text="Add new record" CommandName="InitInsert">
       </asp:LinkButton>
</CommandItemTemplate>

Thnaks,
Shinu.
0
JSON
Top achievements
Rank 1
answered on 06 Jul 2011, 03:25 PM
Again, here is the hierarchy I have created within RadGrid that I need to know how to bind data to (EditMode) I have tried a number of different methods to bind, including those suggested by Telerik - without success.

<RadGrid>
    <MasterTableView>
        <EditItemTemplate>
            <table>
                <tr>
                    <td>
                        <Textbox>   //control to bind
0
shrujan
Top achievements
Rank 1
answered on 07 Jul 2011, 05:25 AM
Hello Shinu
Thanks  for ur reply.
Still it sgiving the same error.
when ever i click the link button "add" the grid get disapeared.
please give a solution for this.
i have used the following code.


<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="toeflUserControl.ascx.cs" Inherits="LaunchPadWebPages.UserControls.toeflUserControl" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>


 <telerik:RadGrid ID="RadGrid2" GridLines="None" runat="server" AllowAutomaticDeletes="True"
            AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True" OnCancelCommand="Grid_Cancel"
            AutoGenerateColumns="False" OnEditCommand="grdInvoicesStoreStyleSelected_EditCommand"
           AllowMultiRowEdit="True" OnUpdateCommand="RadGrid2_UpdateCommand" OnInsertCommand="insertion">
            <PagerStyle Mode="NextPrevAndNumeric" />
            <MasterTableView Width="100%"  EditMode="InPlace" CommandItemDisplay="Top"
                 HorizontalAlign="NotSet" 
                AutoGenerateColumns="False">


                <CommandItemTemplate>
      <asp:LinkButton runat="server" ID="AddNew" Text="Add new record" CommandName="InitInsert" OnClientClick="insertion">
       </asp:LinkButton>
     </CommandItemTemplate>


                <Columns>
                <telerik:GridEditCommandColumn ButtonType="LinkButton" UniqueName="EditCommandColumn">                       
                    </telerik:GridEditCommandColumn>
                   <telerik:GridBoundColumn DataField="studentid" HeaderText="studentid" SortExpression="studentid"
                        UniqueName="studentid" Visible="false"> 
                   </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Type" HeaderText="Type" SortExpression="Type"
                        UniqueName="Type">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="listening" HeaderText="listening"
                        SortExpression="listening" UniqueName="listening">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="writing" HeaderText="writing"
                        SortExpression="writing" UniqueName="writing">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="reading" HeaderText="reading"
                        SortExpression="reading" UniqueName="reading">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Speaking" HeaderText="Speaking"
                        SortExpression="Speaking" UniqueName="Speaking">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="CbtTotal" HeaderText="CbtTotal"
                        SortExpression="CbtTotal" UniqueName="CbtTotal">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="PaperTotal" HeaderText="PaperTotal"
                        SortExpression="PaperTotal" UniqueName="PaperTotal">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="IbtTotal" HeaderText="IbtTotal"
                        SortExpression="IbtTotal" UniqueName="IbtTotal">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="TestDate" HeaderText="TestDate"
                        SortExpression="TestDate" UniqueName="TestDate">
                    </telerik:GridBoundColumn>
                    
                </Columns>
                
            </MasterTableView>
            
        </telerik:RadGrid>
        
0
Shinu
Top achievements
Rank 2
answered on 07 Jul 2011, 05:28 AM
Hello JSON,

You can try the following approach to bind the TextBox control to a datasource field in edit mode.

aspx:
<EditFormSettings EditFormType="Template">
    <FormTemplate>   
          <asp:TextBox ID="text" Text='<%# Bind("Name") %>'
                 runat="server" Visible="true"></asp:TextBox>
   </FormTemplate>  
</EditFormSettings>


Also check the following demo which discusses a similar scenario.
Grid / Form Template Edit Form.

Thanks,
Shinu.
0
JSON
Top achievements
Rank 1
answered on 07 Jul 2011, 12:00 PM
Tried your suggestion and the recommended demo. It appears to have bound the controls, yet nothig is displayed
I initially apply the results of a stored proc to the data source and bind on Page Load, then apply the two way binding                       '<%# Bind("text") %>' as suggested, but no data content is visiible on rendered page.

 

protected void Page_Load(object sender, EventArgs e)

 

{

 

if (!Page.IsPostBack)

 

{

string casenbr = Request.QueryString[

"id"].ToUpper();

 

 

// get list of articles

 

 

DataSet ds = SPs.Get_Articles(casenbr).GetDataSet();

 

RadGrid1.DataSource = ds;

RadGrid1.DataBind();

}
}
}
}
-----------------------------------------------------------------------------------------------------

 


<
telerik:RadGrid id="RadGrid1"

 

 

runat="server"

 

 

PageSize="10"

 

 

AllowSorting="True"

 

 

AutoGenerateColumns="False"

 

 

GridLines="Both"

 

 

AllowAutomaticDeletes="True"

 

 

AllowAutomaticInserts="True"

 

 

AllowAutomaticUpdates="True"

 

 

PagerStyle-HorizontalAlign="Center"

 

 

ShowStatusBar="True"

 

 

AllowMultiRowSelection="True"

 

 

AllowMultiRowEdit="True"

 

 

OnItemInserted="RadGrid1_ItemInserted"

 

 

OnItemUpdated="RadGrid1_ItemUpdated"

 

 

OnInsertCommand="RadGrid1_ItemInsert"

 

 

OnUpdateCommand="RadGrid1_ItemUpdate"

 

 

AllowPaging="True" >

 

 

 

<MasterTableView DataKeyNames="CaseNbr"

 

 

EditMode="PopUp"

 

 

AutoGenerateColumns="False"

 

 

CommandItemDisplay="Top" TableLayout="Auto"

 

 

EditItemStyle-HorizontalAlign="Justify"

 

 

Caption="<br/><h2><b>Articles</b></h2>">

 

 

<EditFormSettings>

 

 

<EditColumn UniqueName="EditCommandColumn" ButtonType="ImageButton"

 

 

CancelImageUrl="~/Images/filterCancel.png"

 

 

UpdateImageUrl="~/Images/selecttag.png"

 

 

InsertImageUrl="~/Images/add-icon[2].png"

 

 

EditImageUrl="~/Images/edit-icon[1].png" >

 

 

</EditColumn>

 

 

</EditFormSettings>

 

 

<EditFormSettings EditFormType="Template">

 

 

<FormTemplate>

 

 

 

<table>

 

 

 

<tr>

 

 

<td><asp:Label runat="server" ID="Label1" Text="Case Nbr:"></asp:Label></td>

 

 

<td><asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CaseNbr") %>'></asp:TextBox></td>

 

 

 

<td><asp:Label runat="server" ID="Label5" Text="Item:"></asp:Label></td>

 

 

<td><asp:TextBox ID="TextBox13" runat="server" Text='<%# Bind("Item") %>'></asp:TextBox></td>

 

 

 

<td><asp:Label runat="server" ID="Label15" Text="Article:"></asp:Label></td>

 

 

<td><asp:TextBox ID="TextBox11" runat="server" Text='<%# Bind("Article") %>'></asp:TextBox></td>

 

 

 

<td><asp:Label runat="server" ID="Label16" Text="Entry Date:"></asp:Label></td>

 

 

<td><asp:TextBox ID="TextBox14" runat="server" Text='<%# Bind("EntryDate") %>'></asp:TextBox></td>

 

 

</tr>

 

 

 

<tr>

 

 

<td><asp:Label runat="server" ID="Label17" Text="Category Code:"></asp:Label></td>

 

 

<td><asp:TextBox ID="TextBox15" runat="server" Text='<%# Bind("Category") %>'></asp:TextBox></td>

 

 

 

<td><asp:Label runat="server" ID="Label18" Text="Discov-By:"></asp:Label></td>

 

 

<td><asp:TextBox ID="TextBox16" runat="server" Text='<%# Bind("DiscoveredBy") %>'></asp:TextBox></td>

 

 

 

<td><asp:Label runat="server" ID="Label19" Text="Owner:"></asp:Label></td>

 

 

<td colspan="2"><asp:TextBox ID="TextBox17" runat="server" Text='<%# Bind("Owner") %>'></asp:TextBox></td>

 

 

</tr>

 

 

</table>
</formtemplate>
</editFormSettings>
0
shrujan
Top achievements
Rank 1
answered on 11 Jul 2011, 07:03 AM
Hello Shinu
How Can i Add a Required field validators to my Radgrid..
0
Princy
Top achievements
Rank 2
answered on 11 Jul 2011, 08:23 AM
Hello Shrujan,

Check the following help documentation which explains adding validators to RadGrid.
Validation.

Thanks,
Princy.
0
JSON
Top achievements
Rank 1
answered on 11 Jul 2011, 11:44 AM
Using some of the provided examples, I was able to resolve my issue.

Thanks,

JSON
Tags
Grid
Asked by
JSON
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
JSON
Top achievements
Rank 1
shrujan
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or