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

design of textbox in grid editmode and automatic insert mode

1 Answer 19 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Swapnil
Top achievements
Rank 1
Swapnil asked on 12 Sep 2013, 09:30 AM
Hi,
i have 1 radgrid in which i am using editmode and automatic insert mode,so i want
1. some css for these textbox to do(rounded corner,mouse hover,focus and width)

2.some margin before top textbox  to give heading

Thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 12 Sep 2013, 12:41 PM
Hello,

Please try with the below code snippet.
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridEditableItem && e.Item.IsInEditMode)
       {
 
           GridEditableItem edititem = (GridEditableItem)e.Item;
           TextBox txtID = edititem["ProductID"].Controls[0] as TextBox;
           TextBox txtName = edititem["ProductName"].Controls[0] as TextBox;
 
           txtName.Width = Unit.Pixel(300);
           txtName.Attributes.Add("onfocus", "return OnFocusAlert(this);");
           //Same way you can also assign other Atribute
           txtName.CssClass = "AssignYourClassForRoundedCorner";
 
       }
   }
function OnFocusAlert(obj) {
                alert(obj);
            }

.................
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" AllowAutomaticInserts="true"
       AllowAutomaticUpdates="true" DataSourceID="SqlDataSource1" OnItemDataBound="RadGrid1_ItemDataBound">
       <MasterTableView CommandItemDisplay="Top" EditMode="InPlace" DataSourceID="SqlDataSource1">
           <Columns>
               <telerik:GridBoundColumn DataField="ProductID" UniqueName="ProductID" HeaderText="ProductID">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="ProductName" UniqueName="ProductName" HeaderText="ProductName">
               </telerik:GridBoundColumn>
               <telerik:GridEditCommandColumn>
               </telerik:GridEditCommandColumn>
           </Columns>
       </MasterTableView>
   </telerik:RadGrid>
   <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:JayeshTestConnectionString %>"
       DeleteCommand="DELETE FROM [Product] WHERE [ProductID] = @ProductID" InsertCommand="INSERT INTO [Product] ([ProductID], [ProductName]) VALUES (@ProductID, @ProductName)"
       SelectCommand="SELECT [ProductID], [ProductName] FROM [Product]" UpdateCommand="UPDATE [Product] SET [ProductName] = @ProductName WHERE [ProductID] = @ProductID">
       <DeleteParameters>
           <asp:Parameter Name="ProductID" Type="Int32" />
       </DeleteParameters>
       <InsertParameters>
           <asp:Parameter Name="ProductID" Type="Int32" />
           <asp:Parameter Name="ProductName" Type="String" />
       </InsertParameters>
       <UpdateParameters>
           <asp:Parameter Name="ProductName" Type="String" />
           <asp:Parameter Name="ProductID" Type="Int32" />
       </UpdateParameters>
   </asp:SqlDataSource>



Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Swapnil
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or