I am using Asp.Net Dynamic Data. I want to remove delete button from List and details page. I dont want to remove it from mark up. Is there any way to remove delete button based on entity and without adding custom pages?
Hi I was able to do it with this code.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton delete = (LinkButton) e.Row.FindControl("DeleteLinkButton");
delete.Visible = false;
}
}
Try Creating a custom page and you will have all control over default pages template. Look following video explains how to do it.
http://www.asp.net/web-forms/videos/aspnet-dynamic-data/how-do-i-make-custom-pages
Related
Hello guys i am using gridview ( from obout ) on my asp.net site. When the user clicks on Edit the griview opens up and shows a template for the clicked row. In there i got a save button. When the user clicks on it i got a simple JS script that pop ups a simple alert.
My problem is that now i need to show a different alert on different situations.
I tried putting this on the update event instead but it wont trigger :
Page.ClientScript.RegisterStartupScript(Me.GetType(), "PopUpWindow", popupscript, False)
I am trying to find how can i have full control on the alert the user will see after the update event.
you can handle GridView's RowDataBound event,Try using this js function onclick
protected void Gridview_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// reference the Delete LinkButton
LinkButton db = (LinkButton)e.Row.Cells[3].Controls[0];
db.OnClientClick = "return confirm('Are you certain you want to delete this questionnaire?');";
}
}
(OR)
See HERE Example
I added controls (i.e. template column) dynamically in grid view and click on button (post back) then grid view populated existing data (i.e.posted data) twice separated by
protected void Page_Init(object sender, EventArgs e)
{
//on init recreated controls
// if (IsPostBack)
{
gvFirst.DataSource = GetData("select top 10 * from Project_Master");
gvFirst.DataBind();
}
}
Sounds like you might be using Auto-generated fields. In design view, click the smart tag on the gridview and click "edit columns." Then uncheck the checkbox that says "Auto-generate fields." I think this should fix your problem if I am understanding you correctly.
I made researching about this subject I could not find proper answer.
In my default.aspx page, I have a treeview. Codes are in default.aspx like below:
protected void Page_Load(object sender, EventArgs e)
{
}
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
Control ucont;
if (TreeView1.SelectedNode.Value == "Yeni Dönem")
{
ucont = LoadControl("usercontrols/yenidonem.ascx");
PlaceHolder1.Controls.Add(ucont);
}
else
{
ucont = LoadControl("usercontrols/tabloktar.ascx");
PlaceHolder1.Controls.Add(ucont);
}
}
I load user controls dnynmicaly. User controls are have button control. I can not fire user control's button click when I load it dynamcally. How can I solve this ?
Thanks.
First of all, I would not recommend adding control dynamically later than in Page_Load event. Other things to remember is that You should add it on each page load and assign unique ID value the control that does not change between postbacks.
In this case, the easiest way would be to always add both controls to the page and show appropriate one using Visibility property.
If that's not suitable for You, try to move the code from TreeView1_SelectedNodeChanged to the Page_Load event and load appropriate control on each postback until it should be changed to another one.
I haven't tested this, so if You have any issues when using thise answer, let me know in the comments and I'll try to help.
I am getting Application name from querystring.
I have GridView control that I can use to insert some Tasks. I have to insert Tasks based on the Application name I am getting in the querystring. I am inserting Record in the GridView footer. Since, application name is coming from Querystring, I want to show it as one item in the GridView footer. How can I do this while Page_Loading time?
Thanks.
You will need to bind to the RowDataBound event and then check the event to see if it is the footer like so:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = Request["ApplicationName"];
}
}
I have a Treeview in a masterpage and a products page in child page.
When i click treeview node i want to bind data to a gridview on the product page.
protected void trvCategoryTab_SelectedNodeChanged(object sender, EventArgs e)
{
if (trvCategoryTab.SelectedNode.Value != string.Empty)
{
Response.Redirect("~/Customer/Products.aspx?Search=" + trvCategoryTab.SelectedNode.Value);
}
}
It's working fine, but the problem is that the page reloads every time. I want to prevent this.
Is there any other method to redirect to the child page?
It sounds like you want to use AJAX.