Radgrid的增删改

protected void RadGrid4_UpdateCommand(object source,

                                          GridCommandEventArgs e)

    {

        var editedItem = e.Item as GridEditableItem ;

        // 获取编辑框里的 taskid

string taskId = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["taskId" ].ToString();

        // 获取编辑框里的控件( html 里可以用 例子 1 和例子二的模式

string taskName = ((TextBox ) editedItem.FindControl("TextBox1" )).Text;

        string description = ((TextBox ) editedItem.FindControl("TextBox2" )).Text;

        string standardtime = ((TextBox ) editedItem.FindControl("TextBox3" )).Text;

 

 

        string updatesql = "update Tasks set taskName='" + taskName + "',description='" + description +

                           "',expectedTaskLength='" + standardtime + "' where taskId='" + taskId +

                           "' and nonproductionTask='false'" ;

        DbConnector .runSql(updatesql);

  // 关闭编辑窗口      

RadGrid4.MasterTableView.Items[editedItem.ItemIndex].Edit = false ;

    }

 

 

    protected void RadGrid4_DeleteCommand(object source, GridCommandEventArgs e)

    {

        string ID = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["taskId" ].ToString();

        string deletesql = "delete from Tasks where taskId='" + ID + "'" ;

        DbConnector .runSql(deletesql);

    }

 

    protected void RadGrid4_InsertCommand(object source, GridCommandEventArgs e)

    {

        var insertedItem = (GridEditFormInsertItem ) e.Item;

        string taskName = ((TextBox ) insertedItem.FindControl("TextBox1" )).Text.Trim();

        string description = ((TextBox ) insertedItem.FindControl("TextBox2" )).Text.Trim();

        string standardtime = ((TextBox ) insertedItem.FindControl("TextBox3" )).Text.Trim();

        string insertQuery =

            "INSERT into  Tasks(taskName,description,expectedTaskLength,nonproductionTask,workTask) values('" +

            taskName + "','" + description + "','" + standardtime + "','false','false')" ;

        DbConnector .runSql(insertQuery);

// 这里是关闭 insert 的窗口

        e.Canceled = true ;

        e.Item.OwnerTableView.IsItemInserted = false ;

        RadGrid4.Rebind();

    }

 

 

 

 

 

例子 1:

    < EditFormSettings EditFormType ="Template">// 这里是设置 editfrom 类型 ,自定义模板

                            < EditColumn UniqueName ="EditCommandColumn1">

                            </ EditColumn >

                            < FormTemplate >

                                taskName:< asp : TextBox ID ="TextBox1" runat ="server"

                                    Text =' <% # bind ("taskName")%> '></ asp : TextBox >

                                < br />

                                description:< asp : TextBox ID ="TextBox2" runat ="server"

                                    Text =' <% # bind ("description")%> '></ asp : TextBox >

                                < br />

                                standardTime:< asp : TextBox ID ="TextBox3" runat ="server"

                                    Text =' <% # bind ("expectedTaskLength")%> '></ asp : TextBox >< asp : RegularExpressionValidator ID ="reg1" runat ="server" ControlToValidate ="TextBox3" ValidationExpression ="^[0-9]*$" ErrorMessage ="Please input the number."></ asp : RegularExpressionValidator >

                                < br />

                                < asp : Button ID ="btnUpdate0" runat ="server" CommandName =' <% # (Container is GridEditFormInsertItem)

                                        ? "PerformInsert"

                                        : "Update"%> ' Text =' <% # (Container is GridEditFormInsertItem) ? "Insert" : "Update"%> ' />

                                 &nbsp;

                                < asp : Button ID ="btnCancel0" runat ="server" CausesValidation ="False"

                                    CommandName ="Cancel" Text ="Cancel" / >

                            </ FormTemplate >

                         </ EditFormSettings >

 

 

例子 2

< Columns >

                            < telerik : GridBoundColumn DataField ="taskId" DataType ="System.Int32"

                                HeaderText ="taskId" ReadOnly ="True" SortExpression ="taskId" UniqueName ="taskId"

                                Visible ="False">

                            </ telerik : GridBoundColumn >

                            < telerik : GridBoundColumn DataField ="taskName" HeaderText ="taskName"

                                SortExpression ="taskName" UniqueName ="taskName" ReadOnly =true>

                            </ telerik : GridBoundColumn >

                            < telerik : GridBoundColumn DataField ="description" HeaderText ="description"

                                SortExpression ="description" UniqueName ="description" ReadOnly =true>

                            </ telerik : GridBoundColumn >

                         

                            < telerik : GridTemplateColumn HeaderText ="Assign">

                                < ItemTemplate >// 这里是自己设置 gridtable 的列

                                   < asp : CheckBox ID ="chb" runat ="server" Checked =' <% # Convert.ToBoolean(Eval("assign")) %> ' OnCheckedChanged ="chb_CheckedChanged" AutoPostBack ="true"   />   

                                </ ItemTemplate >

                                < EditItemTemplate >// 这里是设置 editfrom 里的

                                    < asp : CheckBox ID ="chbItemEdt" runat ="server" Checked =' <% # Convert.ToBoolean(Eval("assign")) %> ' />   

                                </ EditItemTemplate >

                            </ telerik : GridTemplateColumn >

                        </ Columns >

 

 

 


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
您可以使用雷达图的 polar 参数来控制极坐标系的显示,然后使用 radgrid 参数来控制刻度的显示。具体来说,您可以在 polar 参数中设置 radius 和 angle_range 参数来控制雷达图的大小和角度范围,然后在 radgrid 参数中设置 levels 和 grid_type 参数来控制刻度的数量和类型。最后,您可以使用 label 参数来设置刻度的单位。以下是一个示例代码: ```python import matplotlib.pyplot as plt import numpy as np # 生成数据 categories = ['A', 'B', 'C', 'D', 'E'] data = np.random.randint(1, 10, size=(5,)) # 绘制雷达图 fig = plt.figure(figsize=(6, 6)) ax = fig.add_subplot(111, polar=True) theta = np.linspace(0, 2*np.pi, len(categories), endpoint=False) theta = np.concatenate((theta, [theta[0]])) data = np.concatenate((data, [data[0]])) ax.plot(theta, data, 'o-', linewidth=2) ax.fill(theta, data, alpha=0.25) # 设置刻度 ax.set_theta_zero_location('N') ax.set_theta_direction(-1) ax.set_rlim(0, 10) ax.set_rticks(np.arange(0, 10, 2)) ax.set_rlabel_position(22.5) ax.grid(True, linestyle='--', linewidth=1) ax.set_title('Radar Chart', fontsize=14) # 显示刻度单位 ax.set_xlabel('Unit', labelpad=15) ax.set_rlabel_position(180 / len(categories)) ax.set_rgrids(np.arange(2, 10, 2), labels=[str(i) + ' Unit' for i in np.arange(2, 10, 2)]) plt.show() ``` 这段代码会生成一个带有刻度单位的雷达图,其中刻度范围为 2 到 8,单位为 Unit。您可以根据需要修刻度范围和单位。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值