All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:
<
telerik:RadGrid
ID
=
"rdgdr1"
runat
"server"
AutoGenerateColumns
"false"
AutoGenerateEditColumn
"true"
onneeddatasource
"rdgdr1_NeedDataSource"
ondeletecommand
"rdgdr1_DeleteCommand"
oninsertcommand
"rdgdr1_InsertCommand"
onupdatecommand
"rdgdr1_UpdateCommand"
onitemdatabound
"rdgdr1_ItemDataBound"
onitemcommand
"rdgdr1_ItemCommand"
onitemupdated
"rdgdr1_ItemUpdated"
onitemcreated
"rdgdr1_ItemCreated"
>
MasterTableView
DataKeyNames
"OrderID"
CommandItemDisplay
"top"
Columns
telerik:GridBoundColumn
UniqueName
DataField
HeaderText
></
"EmployeeID"
</
public
SqlCommand SqlCommand =
new
SqlCommand();
protected
void
rdgdr1_NeedDataSource(
object
sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
string
selectFilterQuery =
"select top 5 * from [Orders]"
;
SqlCommand.CommandText = selectFilterQuery;
SqlDataAdapter adapter =
SqlDataAdapter(selectFilterQuery, conn);
DataTable dt =
DataTable();
conn.Open();
adapter.Fill(dt);
conn.Close();
rdgdr1.DataSource = dt;
}
rdgdr1_UpdateCommand(
sender, GridCommandEventArgs e)
GridEditableItem editItem = (GridEditableItem)e.Item;
int
index = editItem.ItemIndex;
orderId = editItem.OwnerTableView.DataKeyValues[editItem.ItemIndex][
].ToString();
OrderId = (editItem[
].Controls[0]
as
TextBox).Text;
EmployeeID = (editItem[
OrderDate = (editItem[
"OrderDate"
updateQuery =
"Update Orders set ShipCity='"
+city+
"', EmployeeID='"
+ EmployeeID +
"',OrderDate='"
+ OrderDate +
"'"
where OrderID=
'" + OrderId + "'
";
SqlCommand.CommandText = updateQuery;
SqlCommand.Connection = conn;
SqlCommand.ExecuteNonQuery();
rdgdr1_DeleteCommand(
GridDataItem editItem = (GridDataItem)e.Item;
orderID = editItem.OwnerTableView.DataKeyValues[editItem.ItemIndex][
delQuery=
"delete from orders where OrderID='"
+orderID+
SqlCommand.CommandText = delQuery;
rdgdr1_InsertCommand(
insertQuery =
"insert into Orders (OrderID,EmployeeID) values ('"
+ OrderId +
"','"
);
SqlCommand.CommandText = insertQuery;