编辑和更新 radgrid 中的列
我们最近购买了 Asp.net Ajax 控件。我们正在迁移到 radgrid 的 ASP.NET 网格。在我的网格中,我可以编辑和更新我的行。当我尝试在 radgrid 中实现它时,我遇到了太多错误。任何人都可以帮助我如何做到这一点吗?我需要在哪个命令中编写代码???
我想要的是一旦编辑 radgrid,我只想在编辑后捕获文本框中的文本。请参阅上面修改后的问题。
我在 gridview 中执行的上述功能如下。但我不知道如何做到这一点。
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>
We recently bought Asp.net Ajax control. We are migrating to asp.net grid ti radgrid. In my grid I ma editing and updating my rows. When I am trying to implement that in radgrid I am getting too many errors. Can any one help me how to do that? In which command i need to write the code???
What i want is once i edit the radgrid, i just want to catch the text in the textbox after i edited it. See the modified question above.
the above functionality i did in gridview as follows. But i dont know how to do it 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)
{
}
}
my radgrid aspx file code
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从 Telerik 网站上提供的演示开始,然后从那里开始工作。
或者,使用 radgrid 从头开始重建网格。
你发布的内容根本没有帮助。这是一堵文字墙,没有任何具体错误的指示。我们这里不是读心术的人。
Start with the demos available on Telerik's site, and work from there.
Or, rebuild your grid from scratch using the radgrid.
What you've posted is not helpful at all. It's a wall of text with no direction as to any sort of specific error. We're not mind readers here.