我们最近购买了Asp.net Ajax控件。我们正在迁移到asp.net grid ti radgrid。在我的网格中,我可以编辑和更新我的行。当我试图在radgrid中实现它时,我得到了太多错误。任何人都可以帮我怎么做?在哪个命令我需要写代码???
我想要的是一旦我编辑了radgrid,我只想在编辑后捕获文本框中的文本。请参阅上面修改后的问题。
我在gridview中做的上述功能如下。但我不知道怎么做radgrid。
protected void gvCktMap_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
if (Session["TaskID"] != null)
{
string strTaskID = (string)Session["TaskID"];
if (strTaskID != string.Empty)
{
bool bolStatus = false;
clsTaskUpdates_BL objBL = new clsTaskUpdates_BL();
Label lblOrdID = (Label)gvCktMap.Rows[e.RowIndex].FindControl("lblorderId");
string strOrdId = lblOrdID.Text;
DataSet dsStatus = objBL.getTaskStatus_BL(lblOrdID.Text.Trim(), strTaskID.Trim());
if (dsStatus.Tables[0].Rows.Count > 0)
{
if (dsStatus.Tables[0].Rows[0][0].ToString() == "3" || dsStatus.Tables[0].Rows[0][0].ToString() == "4")
bolStatus = true;
}
if (!bolStatus)
{
Session["SearchRes"] = null;
if (strTaskID == "200")
{
TextBox txtClarifyID = (TextBox)gvCktMap.Rows[e.RowIndex].FindControl("txtClarifyAccountNbr");
TextBox txtSiteID = (TextBox)gvCktMap.Rows[e.RowIndex].FindControl("txtSiteID");
TextBox txtQuoteID = (TextBox)gvCktMap.Rows[e.RowIndex].FindControl("txtQuoteID");
CheckBox chkEDP = (CheckBox)gvCktMap.Rows[e.RowIndex].FindControl("chkEditEDPCreated?");
objBL.setTask200_Bl(lblOrdID.Text, txtClarifyID.Text, txtSiteID.Text, txtQuoteID.Text, chkEDP.Checked);
gvCktMap.EditIndex = -1;
bingGrid();
}
else if (strTaskID == "206")
{
TextBox txtConfigGenDate = (TextBox)gvCktMap.Rows[e.RowIndex].FindControl("txtConfigGenDate");
objBL.setTask206_Bl(lblOrdID.Text, txtConfigGenDate.Text);
gvCktMap.EditIndex = -1;
bingGrid();
}
else if (strTaskID == "207")
{
TextBox txtCPEShipDate = (TextBox)gvCktMap.Rows[e.RowIndex].FindControl("txtCPEShipDate");
TextBox txtPackageSlip = (TextBox)gvCktMap.Rows[e.RowIndex].FindControl("txtPackageSlip");
objBL.setTask207_Bl(lblOrdID.Text, txtCPEShipDate.Text.Trim(), txtPackageSlip.Text.Trim());
gvCktMap.EditIndex = -1;
bingGrid();
}
else if (strTaskID == "208")
{
TextBox txtCORECMNumber = (TextBox)gvCktMap.Rows[e.RowIndex].FindControl("txtCORECMNumber");
TextBox txtReqSMImpDate = (TextBox)gvCktMap.Rows[e.RowIndex].FindControl("txtReqSMImpDate");
objBL.setTask208_Bl(lblOrdID.Text, txtReqSMImpDate.Text.Trim(), txtCORECMNumber.Text.Trim());
gvCktMap.EditIndex = -1;
bingGrid();
}
}
else
{
// ScriptManager.RegisterClientScriptBlock(this.up, this.GetType(), "updateMsg", "<script>alert('The task has been completed by '" + dsStatus.Tables[0].Rows[0]["tskCompletedBy"].ToString() + " + '. Refresh the task list using F5')</script>", false);
ScriptManager.RegisterClientScriptBlock(this.up,up.GetType(), "updateMsg", "fnStatusMsg()", true);
gvCktMap.EditIndex = -1;
bingGrid();
}
}
}
}
catch (Exception ex)
{
}
}
我的radgrid aspx文件代码
<telerik:RadGrid ID="rg200" runat="server" AutoGenerateColumns="False" PageSize="30"
Height="550px" OnNeedDataSource="rg200_NeedDataSource" Width="100%" AllowPaging="True"
AllowSorting="True" AllowMultiRowSelection="True" EnableHeaderContextMenu="True"
GridLines="None" EnableHeaderContextFilterMenu="True" AllowMultiRowEdit="True"
AllowFilteringByColumn="True" OnPreRender="rg200_PreRender" OnItemCreated="rg200_ItemCreated"
EnableViewState="False" OnUpdateCommand="rg200_UpdateCommand">
<HeaderStyle Height="20px" BackColor="#004000" Font-Size="8pt" Font-Bold="True" ForeColor="White"
HorizontalAlign="Center" BorderColor="White" BorderWidth="1px" />
<ExportSettings IgnorePaging="true" ExportOnlyData="true">
<Pdf AllowModify="false" AllowPrinting="true" PageBottomMargin="" PageFooterMargin=""
PageHeaderMargin="" PageHeight="11in" PageLeftMargin="" PageRightMargin="" PageTopMargin=""
PageWidth="14in" />
</ExportSettings>
<MasterTableView DataKeyNames="orderId" CommandItemDisplay="Top" EditMode="InPlace">
<CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true"
ShowExportToCsvButton="true" ShowExportToPdfButton="true" ShowAddNewRecordButton="false" />
<RowIndicatorColumn Visible="True">
</RowIndicatorColumn>
<Columns>
<telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-Width="3%"
ItemStyle-Width="3%">
<HeaderStyle Width="3%"></HeaderStyle>
<ItemStyle Width="3%"></ItemStyle>
</telerik:GridClientSelectColumn>
<telerik:GridBoundColumn UniqueName="sId" HeaderText="sId" DataField="sId" Visible="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="orderId" HeaderText="orderId" DataField="orderId"
Visible="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Customer Name" HeaderText="Customer Name" DataField="Customer Name"
ReadOnly="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Market Name" HeaderText="Market Name" DataField="Market Name"
ReadOnly="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="LOB" HeaderText="LOB" DataField="LOB" ReadOnly="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Headend Name" HeaderText="Headend Name" DataField="Headend Name"
ReadOnly="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Project Name" HeaderText="Project Name" DataField="Project Name"
ReadOnly="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Site Name" HeaderText="Site Name" DataField="Site Name"
ReadOnly="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Task Status" HeaderText="Task Status" DataField="Task Status"
ReadOnly="true">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn UniqueName="Clarify Account Nbr" HeaderText="Clarify Account Nbr"
DataField="Clarify Account Nbr">
<ItemTemplate>
<asp:Label ID="lblClarifyAccountNbr" Text='<%# Eval("Clarify Account Nbr") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtClarifyAccountNbr" Text='<%# Eval("Clarify Account Nbr") %>'
runat="server"></asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<%-- <telerik:GridBoundColumn UniqueName="Clarify Account Nbr" HeaderText="Clarify Account Nbr"
DataField="Clarify Account Nbr">
</telerik:GridBoundColumn>--%>
<telerik:GridBoundColumn UniqueName="Site ID" HeaderText="Site ID" DataField="Site ID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Quote ID" HeaderText="Quote ID" DataField="Quote ID">
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn UniqueName="EDP Created?" HeaderText="EDP Created?" DataField="EDP Created?">
</telerik:GridCheckBoxColumn>
<telerik:GridEditCommandColumn UniqueName="ECC200">
</telerik:GridEditCommandColumn>
</Columns>
<PagerStyle AlwaysVisible="True"></PagerStyle>
</MasterTableView>
</telerik:RadGrid>
答案 0 :(得分:0)
从Telerik网站上提供的演示开始,然后从那里开始工作。
或者,使用radgrid从头开始重建网格。
您发布的内容根本没用。这是一个文本墙,没有任何特定错误的方向。我们不介意读者。