| <telerik:RadGrid ID="RadGrid1" runat="server" Skin="trublue" EnableEmbeddedSkins="False" |
| GridLines="None" Style="left: 25px; position: relative; top: 14px; text-align: left;" |
| Width="750px" AllowPaging="True" PageSize="20" AutoGenerateColumns="False"> |
| <PagerStyle Mode="NumericPages" /> |
| <HeaderContextMenu EnableEmbeddedSkins="False"> |
| </HeaderContextMenu> |
| <MasterTableView DataKeyNames="TransactionsID"> |
| <DetailTables> |
| <telerik:GridTableView Name="TransDetails" runat="server" DataKeyNames="CheckNumber"> |
| <NestedViewTemplate> |
| <asp:Panel ID="Container" runat="server"> |
| <telerik:RadTabStrip ID="Gridtab1" runat="server" Skin="trublue" EnableEmbeddedSkins="False" |
| MultiPageID="gridmultypage1"> |
| <Tabs> |
| <telerik:RadTab runat="server" PageViewID="gridpageview1" Selected="true" Text="Transactions Details"> |
| </telerik:RadTab> |
| <telerik:RadTab runat="server" PageViewID="gridpageview2" Selected="true" Text="Attachment Details"> |
| </telerik:RadTab> |
| </Tabs> |
| </telerik:RadTabStrip> |
| <telerik:RadMultiPage ID="gridmultypage1" SelectedIndex="0" runat="server"> |
| <telerik:RadPageView ID="gridpageview1" runat="server"> |
| <br /> |
| <table style="position: static; text-align: left"> |
| <tbody> |
| <tr> |
| <td style="width: 100px"> |
| </td> |
| <td style="width: 100px"> |
| <asp:Label Style="position: static" ID="lblchkno" runat="server" Width="115px" Text="Cheque Number"> |
| </asp:Label></td> |
| <td> |
| :</td> |
| <td style="width: 224px"> |
| <asp:Label Style="position: static" ID="lblchequenumber" runat="server" Width="260px"></asp:Label> |
| </td> |
| <td style="width: 12px"> |
| </td> |
| </tr> |
| <tr> |
| <td style="width: 100px"> |
| </td> |
| <td style="width: 100px"> |
| <asp:Label Style="position: static" ID="lblchkamount" runat="server" Text="Cheque Amount"> |
| </asp:Label></td> |
| <td> |
| :</td> |
| <td style="width: 224px"> |
| <asp:Label Style="position: static" ID="lblchequeamount" runat="server" Width="260px"></asp:Label> |
| </td> |
| <td style="width: 12px"> |
| </td> |
| </tr> |
| <tr> |
| <td style="width: 100px"> |
| </td> |
| <td style="width: 100px"> |
| <asp:Label Style="position: static" ID="lblchkdate" runat="server" Text="Cheque Date"></asp:Label></td> |
| <td> |
| :</td> |
| <td style="width: 224px"> |
| <asp:Label Style="position: static" ID="lblchequedate" runat="server" Width="260px"></asp:Label> |
| </td> |
| <td style="width: 12px"> |
| </td> |
| </tr> |
| <tr> |
| <td style="width: 100px"> |
| </td> |
| <td style="width: 100px"> |
| <asp:Label Style="position: static" ID="lblcltname" runat="server" Text="Client Name"></asp:Label> |
| </td> |
| <td> |
| :</td> |
| <td style="width: 224px"> |
| <asp:Label Style="position: static" ID="lblclientname" runat="server" Width="260px"></asp:Label> |
| </td> |
| <td style="width: 12px"> |
| </td> |
| </tr> |
| <tr> |
| <td style="width: 100px"> |
| </td> |
| <td style="width: 100px"> |
| <asp:Label Style="position: static" ID="lblbnkname" runat="server" Text="Bank Name"></asp:Label> |
| </td> |
| <td> |
| :</td> |
| <td style="width: 224px"> |
| <asp:Label Style="position: static" ID="lblbankname" runat="server" Width="260px"></asp:Label> |
| </td> |
| <td style="width: 12px"> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| <br /> |
| </telerik:RadPageView> |
| <telerik:RadPageView ID="RadPageView2" runat="server"> |
| <br /> |
| <table> |
| <tr> |
| <td> |
| <telerik:RadGrid ID="RadGridDD" Skin="trublue" EnableEmbeddedSkins="False" runat="server" |
| AutoGenerateColumns="false"> |
| <ClientSettings> |
| <Selecting AllowRowSelect="true" /> |
| </ClientSettings> |
| <MasterTableView> |
| <Columns> |
| <telerik:GridTemplateColumn> |
| <HeaderTemplate> |
| Download |
| </HeaderTemplate> |
| <ItemTemplate> |
| <asp:LinkButton ID="btndownload" runat="server" Text="Download" OnClick="btndownload_click"></asp:LinkButton> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="id" HeaderText="id" UniqueName="id" Visible="false"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="transno" HeaderText="transno" UniqueName="transno" |
| Visible="false"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="docname" HeaderText="Document Name" UniqueName="docname"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="filename" HeaderText="File Name" UniqueName="filename"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
| </td> |
| </tr> |
| <tr> |
| <td> |
| <table style="position: static"> |
| <tr> |
| <td style="width: 100px"> |
| <asp:Button ID="btnfront" runat="server" Style="position: static" OnClick="btnfrontgrd_click" Enabled="false" |
| Text="View Front" /></td> |
| <td style="width: 100px"> |
| <asp:Button ID="btnback" runat="server" Style="position: static" OnClick="btnbackgrd_click" Enabled="false" |
| Text="View Back" /></td> |
| <td style="width: 100px"> |
| </td> |
| <td style="width: 100px"> |
| </td> |
| <td style="width: 100px"> |
| </td> |
| <td style="width: 100px"> |
| </td> |
| <td style="width: 100px"> |
| </td> |
| <td style="width: 100px"> |
| <asp:Button ID="btndownloadgrd" runat="server" Style="position: static" OnClick="btndownloadgrd_click" Enabled="false" |
| Text="Download" /></td> |
| <td style="width: 100px"> |
| <asp:Button ID="btnprintgrd" runat="server" Style="position: static" Text="Print" |
| Visible="False" /></td> |
| </tr> |
| </table> |
| </td> |
| </tr> |
| </table> |
| <br /> |
| <iframe id="frameimage" style="overflow: scroll;" runat="server" width="674px" height="640px"> |
| </iframe> |
| </telerik:RadPageView> |
| </telerik:RadMultiPage> |
| </asp:Panel> |
| </NestedViewTemplate> |
| <Columns> |
| <telerik:GridBoundColumn DataField="CheckNumber" HeaderText="CheckNumber" UniqueName="CheckNumber"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="CheckDate" HeaderText="CheckDate" UniqueName="CheckDate"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="CheckReceivedOn" HeaderText="CheckReceivedOn" |
| UniqueName="CheckReceivedOn"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="CheckAmount" HeaderText="CheckAmount" UniqueName="CheckAmount"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="DepositeDate" HeaderText="DepositeDate" UniqueName="DepositeDate"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="InvoiceNo" HeaderText="InvoiceNo" UniqueName="InvoiceNo"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| <ExpandCollapseColumn Visible="True"> |
| </ExpandCollapseColumn> |
| <EditFormSettings> |
| <EditColumn CancelImageUrl="trublue/Grid/Cancel.gif" EditImageUrl="trublue/Grid/Edit.gif" |
| InsertImageUrl="trublue/Grid/Update.gif" UpdateImageUrl="trublue/Grid/Update.gif"> |
| </EditColumn> |
| </EditFormSettings> |
| </telerik:GridTableView> |
| </DetailTables> |
| <Columns> |
| <telerik:GridBoundColumn DataField="TransactionsID" HeaderText="TransactionsID" UniqueName="TransactionsID"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="DepositeDate" HeaderText="DepositeDate" UniqueName="DepositeDate"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="ChecksCount" HeaderText="ChecksCount" UniqueName="ChecksCount"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="TotalAmount" HeaderText="TotalAmount" UniqueName="TotalAmount"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| <ExpandCollapseColumn Visible="True"> |
| </ExpandCollapseColumn> |
| <EditFormSettings> |
| <EditColumn CancelImageUrl="trublue/Grid/Cancel.gif" EditImageUrl="trublue/Grid/Edit.gif" |
| InsertImageUrl="trublue/Grid/Update.gif" UpdateImageUrl="trublue/Grid/Update.gif"> |
| </EditColumn> |
| </EditFormSettings> |
| </MasterTableView> |
| <ClientSettings> |
| <Selecting AllowRowSelect="True" /> |
| <ClientEvents OnRowDblClick="RowDblClicked" /> |
| </ClientSettings> |
| <FilterMenu EnableEmbeddedSkins="False"> |
| </FilterMenu> |
| </telerik:RadGrid> |
<rad:RadUpload runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false" />
<rad:RadUpload runat="server" ID="documentUpload" InitialFileInputsCount="3" Skin="Default" />

Here is the following Code
<radG:RadGrid ID="RadGrid1" Skin="Lime" runat="server" CssClass="RadGrid" GridLines="None" AllowPaging="True" PageSize="5" AllowSorting="True" Width="99%" AutoGenerateColumns="False" EnableAJAX="True" ShowStatusBar="true" HorizontalAlign="NotSet" Source="RadGrid1_NeedDataSource" OnUpdateCommand="RadGrid1_UpdateCommand" OnInsertCommand="RadGrid1_InsertCommand"
OnDeleteCommand="RadGrid1_DeleteCommand">
<PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
<MasterTableView CommandItemDisplay="Top" GridLines="None" DataKeyNames="CustomerID"
EditMode="InPlace">
<Columns>
<radG:GridEditCommandColumn>
</radG:GridEditCommandColumn>
<radG:GridBoundColumn UniqueName="CustomerID" HeaderText="ID" ReadOnly="true" DataField="CustomerID">
</radG:GridBoundColumn>
<radG:GridBoundColumn UniqueName="CompanyName" HeaderText="CompanyName" DataField="CompanyName">
</radG:GridBoundColumn>
<radG:GridBoundColumn UniqueName="ContactName" HeaderText="ContactName" DataField="ContactName">
</radG:GridBoundColumn>
<radG:GridBoundColumn UniqueName="Address" HeaderText="Address" DataField="Address">
</radG:GridBoundColumn>
<radG:GridButtonColumn CommandName="Delete" Text="Delete">
</radG:GridButtonColumn>
</Columns>
<EditFormSettings EditFormType="Template">
<EditColumn UniqueName="EditCommandColumn1">
</EditColumn>
<FormTemplate>
<table id="Table2" cellspacing="2" cellpadding="1" width="250" border="1" rules="none"
style="border-collapse: collapse">
<tr>
<td>
<table id="Table3" cellspacing="1" cellpadding="1" width="250" border="0">
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
CustomerID:
</td>
<td>
<asp:TextBox ID="txtCustomerID" MaxLength="5" Visible='<% # (Container as GridItem).OwnerTableView.IsItemInserted %>'
runat="server">
</asp:TextBox>
</td>
</tr>
<tr>
<td>
CompanyName:
</td>
<td>
<asp:TextBox ID="txtCompanyName" runat="server" Text='<%# Eval( "CompanyName" ) %>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td>
ContactName:
</td>
<td>
<asp:TextBox ID="txtContactName" runat="server" Text='<%# Eval( "ContactName") %>'
TabIndex="1">
</asp:TextBox>
</td>
</tr>
<tr>
<td>
Address:
</td>
<td>
<asp:TextBox ID="txtAddress" runat="server" Text='<%# Eval( "Address") %>' TabIndex="2">
</asp:TextBox>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<b>Company Info:</b>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="btnUpdate" Text='<%# (Container as GridItem).OwnerTableView.IsItemInserted ? "Insert" : "Update" %>'
runat="server" CommandName='<%# (Container as GridItem).OwnerTableView.IsItemInserted ? "PerformInsert" : "Update" %>'>
</asp:Button>
<asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
CommandName="Cancel"></asp:Button>
</td>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
<ExpandCollapseColumn Visible="False">
<HeaderStyle Width="19px" />
</ExpandCollapseColumn>
<RowIndicatorColumn Visible="False">
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
</MasterTableView>
</radG:RadGrid>
Code Behined:-
//Declare a global DataTable dtTable
public static DataTable dtTable;
//Declare a global SqlConnection SqlConnection
//public SqlConnection SqlConnection = new SqlConnection("Data Source=local;Initial Catalog=Northwind;User ID=**");
public SqlConnection SqlConnection = new SqlConnection("Data Source=(local);Initial Catalog=Northwind;uid=sa;pwd=password;");
//Declare a global SqlDataAdapter SqlDataAdapter
public SqlDataAdapter SqlDataAdapter = new SqlDataAdapter();
//Declare a global SqlCommand SqlCommand
public SqlCommand SqlCommand = new SqlCommand();
protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
//Populate the Radgrid
dtTable = new DataTable();
//Open the SqlConnection
SqlConnection.Open();
try
{
//Select Query to populate the RadGrid with data from table Customers.
string selectQuery = "SELECT CustomerID,CompanyName,ContactName,Address FROM Customers";
SqlDataAdapter.SelectCommand = new SqlCommand(selectQuery, SqlConnection);
SqlDataAdapter.Fill(dtTable);
RadGrid1.DataSource = dtTable;
}
finally
{
//Close the SqlConnection
SqlConnection.Close();
}
}
protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
{
//Get the GridEditableItem of the RadGrid
GridEditableItem editedItem = e.Item as GridEditableItem;
//Get the primary key value using the DataKeyValue.
string CustomerID = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["CustomerID"].ToString();
//Access the textbox from the edit form template and store the values in string variables.
string CompanyName= (editedItem.FindControl("txtCompanyName") as TextBox).Text;
string ContactName = (editedItem.FindControl("txtContactName") as TextBox).Text;
string Address = (editedItem.FindControl("txtAddress") as TextBox).Text;
try
{
//Open the SqlConnection
SqlConnection.Open();
//Update Query to update the Datatable
string updateQuery = "UPDATE Customers set CompanyName='"+CompanyName+"',ContactName='"+ContactName+"',Address='"+Address+"' where CustomerID='" + CustomerID+"'";
SqlCommand.CommandText = updateQuery;
SqlCommand.Connection = SqlConnection;
SqlCommand.ExecuteNonQuery();
//Close the SqlConnection
SqlConnection.Close();
}
catch (Exception ex)
{
RadGrid1.Controls.Add(new LiteralControl("Unable to update Customers. Reason: " + ex.Message));
e.Canceled = true;
}
}
protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)
{
//Get the GridEditFormInsertItem of the RadGrid
GridDataInsertItem insertedItem = (GridDataInsertItem)e.Item;
//GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item;
//Access the textbox from the insert form template and store the values in string variables.
string CustomerID = (insertedItem.FindControl("txtCustomerID") as TextBox).Text;
string CompanyName = (insertedItem.FindControl("txtCompanyName") as TextBox).Text;
string ContactName = (insertedItem.FindControl("txtContactName") as TextBox).Text;
string Address = (insertedItem.FindControl("txtAddress") as TextBox).Text;
try
{
//Open the SqlConnection
SqlConnection.Open();
//Update Query to insert into the database
string insertQuery = "INSERT into Customers(CustomerID,CompanyName,ContactName,Address) values('"+CustomerID+"','"+ CompanyName + "','"+ContactName+"','"+Address+"')";
SqlCommand.CommandText = insertQuery;
SqlCommand.Connection = SqlConnection;
SqlCommand.ExecuteNonQuery();
//Close the SqlConnection
SqlConnection.Close();
}
catch (Exception ex)
{
RadGrid1.Controls.Add(new LiteralControl("Unable to insert Customers. Reason: " + ex.Message));
e.Canceled = true;
}
}
protected void RadGrid1_DeleteCommand(object source, GridCommandEventArgs e)
{
//Get the GridDataItem of the RadGrid
GridDataItem item = (GridDataItem)e.Item;
//Get the primary key value using the DataKeyValue.
string CustomerID = item.OwnerTableView.DataKeyValues[item.ItemIndex]["CustomerID"].ToString();
try
{
//Open the SqlConnection
SqlConnection.Open();
string deleteQuery = "DELETE from Customers where CustomerID='" + CustomerID + "'";
SqlCommand.CommandText = deleteQuery;
SqlCommand.Connection = SqlConnection;
SqlCommand.ExecuteNonQuery();
//Close the SqlConnection
SqlConnection.Close();
}
catch (Exception ex)
{
RadGrid1.Controls.Add(new LiteralControl("Unable to delete Customers. Reason: " + ex.Message));
e.Canceled = true;
}
}
But I am not able to either Insert/Update Records.
Please Help me in this regards.
I want to Insert/Update Records only in In-Place Mode.
At the same time I want to Bind the Combo Box(Which is Grid) from Other table recors.
Please Guide me…..