I work in ASP.NET c# and MySQL database.
In my gridView I have added this code pagination.
<PagerTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="/Images/bot_back_1.gif"
CommandArgument="First" CommandName="Page" Visible="true" />
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="/Images/bot_back.gif"
CommandArgument="Prev" CommandName="Page" Visible="true" />
Page
<asp:DropDownList ID="ddlPages" runat="server" AutoPostBack="True" CssClass="ddl_Class"
OnSelectedIndexChanged="ddlPages_SelectedIndexChanged" Visible="true">
</asp:DropDownList>
of
<asp:Label ID="lblPageCount" runat="server"></asp:Label>
<asp:ImageButton ID="ImageButton3" runat="server" ImageUrl="/Images/bot_next.gif"
CommandArgument="Next" CommandName="Page" Visible="true" />
<asp:ImageButton ID="ImageButton4" runat="server" ImageUrl="/Images/bot_next_1.gif"
CommandArgument="Last" CommandName="Page" Visible="true" />
</PagerTemplate>
</asp:GridView>
<asp:ImageButton ID="btnAdd" runat="server" Visible="true" OnClick="btnAdd_Click" ImageUrl="/Images/Add_button.gif" />
Now I need to set as visible false all the content on PagerTemplate when is activate :
protected void btnAdd_Click(object sender, ImageClickEventArgs e)
{
gvProducts.ShowFooter = true;
btnAdd.Visible = false;
BindData();
}
I have tried with :
protected void btnAdd_Click(object sender, ImageClickEventArgs e)
{
gvProducts.ShowFooter = true;
btnAdd.Visible = false;
ImageButton1.Visible = false;
BindData();
}
But I have error :
CS0103: The name 'ImageButton1' does not exist in the current context.
Can you please help me figure out the problem?
Thanks in advance.
you have to use the method FindControl() to determine the Control
ImageButton btn = (ImageButton)gvProducts.BottomPagerRow.FindControl("ImageButton1");
btn.Visible = false;
Related
Here is my aspx file content.
<asp:UpdatePanel ID="UpdatePanel1" runat="server" OnUnload="UpdatePanel_Unload">
<ContentTemplate>
<table>
<tr>
<td>
<input id="hdnAID" type="hidden" runat="server" />
<asp:GridView ID="GridView1" runat="server" OnRowCancelingEdit="GridView1_RowCancelingEdit"
OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnRowDataBound="GridView1_RowDataBound" OnDataBound="GridView1_DataBound"
DataKeyNames="GeneralSettingID" EnableViewState="true">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<GridEditPopupMenu:GridEditPopupMenu ID="GridEditPopupMenu1" runat="server" currenttemplate="ItemTemplate" ShowDeleteLink="0" />
</ItemTemplate>
<EditItemTemplate>
<GridEditPopupMenu:GridEditPopupMenu ID="GridEditPopupMenu1" runat="server" currenttemplate="EditItemTemplate" />
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="GeneralSettingID" HeaderText="SettingNo" ReadOnly="true" />
<asp:TemplateField HeaderText="SettingName">
<ItemTemplate>
<asp:Label ID="Label25" runat="server" Text='<%# Eval("GeneralSettingName") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtUpdateGeneralSettingName" onfocus="this.blur();" runat="server" Text='<%# Bind("GeneralSettingName") %>'
Width="350px" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Values">
<ItemTemplate>
<asp:Label ID="Label23" runat="server" Text='<%# Eval("GeneralSettingValue") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtUpdateGeneralSettingValue" runat="server" Text='<%# Bind("GeneralSettingValue") %>'
Width="600px" TextMode="MultiLine" Rows="6" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Company1">
<ItemTemplate>
<asp:Label ID="Label28" runat="server" Text='<%# Eval("GeneralSettingCompany") %>' />
</ItemTemplate>
<ItemTemplate>
<asp:TextBox ID="txtUpdateGeneralSettingCompany" runat="server" Text='<%# Bind("GeneralSettingCompany") %>'
Width="100px" TextMode="MultiLine" Rows="1" Enabled="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Company2">
<ItemTemplate>
<asp:DropDownList ID="drpCompanyList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="drpCompanyList_SelectedIndexChanged" DataTextField="CompanyName" DataValueField="CompanyID"></asp:DropDownList>
<input id="hdnCompanyId" type="hidden" value='<%# Eval("GeneralSettingCompany") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
Here is the .cs side .
private LMSDataAccess.LookupsDataContext LkpDC = new LMSDataAccess.LookupsDataContext(ConfigFile.DBConnStr);
private System.Collections.Generic.List<LMSDataAccess.GeneralSetting> GeneralSettingList = null;
protected void Page_Load(object sender, EventArgs e)
{
base.ModuleID = 27;
if (!IsPostBack)
{
if (Request["AID"] != null)
hdnAID.Value = Request["AID"];
BindData();
}
}
private void BindData()
{
GeneralSettingList = LkpDC.GeneralSettingsGetAll(Common.NVLInt(hdnAID.Value),null).ToList();
GridView1.DataSource = GeneralSettingList;
GridView1.DataBind();
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
BindData();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
BindData();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox txtUpdateGeneralSettingName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtUpdateGeneralSettingName");
TextBox txtUpdateGeneralSettingValue = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtUpdateGeneralSettingValue");
var hdnCompany = (HiddenField)GridView1.Rows[e.RowIndex].FindControl("hdnCompanyId") as HiddenField;
string KeyValue = GridView1.DataKeys[e.RowIndex].Value.ToString();
LkpDC.GeneralSettingsUpdate(Convert.ToInt32(KeyValue),
txtUpdateGeneralSettingName.Text,
txtUpdateGeneralSettingValue.Text,
Convert.ToInt32(hdnCompany.Value));
GridView1.EditIndex = -1;
BindData();
ResultCode = 0;
}
protected List<LMSDataAccess.Company> GetAllCompanies()
{
System.Collections.Generic.List<LMSDataAccess.Company> CompanyList = null;
LMSDataAccess.OrganizationDataContext OrgDC = new LMSDataAccess.OrganizationDataContext(ConfigFile.DBConnStr);
CompanyList = OrgDC.CompaniesGetAll(null).ToList();
return CompanyList;
}
protected void drpCompanyList_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddl = (DropDownList)sender;
GridViewRow row = (GridViewRow)ddl.Parent.Parent;
var hdnCompany = row.FindControl("hdnCompanyId") as HiddenField;
hdnCompany.Value = ddl.SelectedValue;
}
protected void GridView1_RowDataBound(object sender,GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
var ddl = e.Row.FindControl("drpCompanyList") as DropDownList;
//here is the problem.
var hdn = e.Row.FindControl("hdnCompanyId") as HiddenField;
if (ddl != null)
{
ddl.DataSource = GetAllCompanies();
ddl.DataValueField = "CompanyID";
ddl.DataTextField = "CompanyName";
ddl.DataBind();
}
}
}
My beloved problem is not being able to get hdnCompanyId element when GridView1_RowDataBound and drpCompanyList_SelectedIndexChangedfired.I am always getting null.(as showed at the commented line )
I have tried under GridView1_RowDataBound event method like e.Row.FindControl("hdnCompanyId")
but it did not work.
My final aim is to setting and getting this element to control selected items of my dropdownlist.
I think the code is well written but I guess I am missing something about hierarchy of the user control elements.
Can you help me about what I am missing?
I have found that the problem was choosing the wrong casting type of the input.It must be HtmlInputHidden rather than HiddenField.I hope someone can get useful info from that question.
I’m using code behind from Microsoft’s FormView.BottomPagerRow Property article. I’m getting error Object reference not set to an instance of an object on Label pageNum = (Label)pagerRow.Cells[0].FindControl("PageNumberLabel");
How do I display the pager template when there is only one record on the page?
protected void fvWriteUp_DataBound(object sender, EventArgs e)
{
int totalPages = fvWriteUp.PageCount;
int itemCount = fvWriteUp.DataItemCount;
// Get the pager row. From MS FormView.BottomPagerRow Property
FormViewRow pagerRow = fvWriteUp.BottomPagerRow;
// Get the Label controls that display the current page information from the pager row.
Label pageNum =
(Label)pagerRow.Cells[0].FindControl("PageNumberLabel");
Label totalNum =
(Label)pagerRow.Cells[0].FindControl("TotalPagesLabel");
if ((pageNum != null) && (totalNum != null))
{
// Update the Label controls with the current page values.
int page = fvWriteUp.PageIndex + 1;
int count = fvWriteUp.PageCount;
pageNum.Text = page.ToString();
totalNum.Text = count.ToString();
}
}
<PagerTemplate>
<asp:Table CssClass="fvFooter" ID="RecordNav" runat="server">
<asp:TableRow
ID="TableRow4"
runat="server">
<asp:TableCell CssClass="recNav">
<asp:Button ID="btnFirst" CssClass="btn btnRecNav" CommandName="Page" CommandArgument="First" Text="First" runat="server" />
<asp:Button ID="btnPrevious" CssClass="btn btnRecNav" CommandName="Page" CommandArgument="Prev" Text="Previous" runat="server" />
<asp:Button ID="btnNext" CssClass="btn btnRecNav" CommandName="Page" CommandArgument="Next" Text="Next" runat="server" />
<asp:Button ID="btnLast" CssClass="btn btnRecNav" CommandName="Page" CommandArgument="Last" Text="Last" runat="server" />
</asp:TableCell><asp:TableCell CssClass="recCounter">
<asp:Label CssClass="lblRecs" ID="lblRecs1" runat="server" Text="Record"></asp:Label>
<asp:Label CssClass="lblRecCount" ID="PageNumberLabel" runat="server"></asp:Label>
<asp:Label CssClass="lblRecs" ID="lblRecs2" runat="server" Text="of"></asp:Label>
<asp:Label CssClass="lblRecCount" ID="TotalPagesLabel" runat="server"></asp:Label>
</asp:TableCell><asp:TableCell></asp:TableCell></asp:TableRow></asp:Table>
</PagerTemplate>
<PagerSettings FirstPageText="First" LastPageText="Last" Mode="NextPreviousFirstLast" NextPageText="Next" PreviousPageText="Previous" Position="Bottom" />
I’ve tried code like this in PreRender without luck
protected void fvWriteUp_PreRender(object sender, EventArgs e)
{
FormViewRow pagerRow = fvWriteUp.BottomPagerRow;
if (pagerRow != null && pagerRow.Visible == false)
{
pagerRow.Visible = true;
fvWriteUp.BottomPagerRow.Visible = true;
}
}
You might want to check for null on BottomPagerRow property for when there's no data populating your grid.
if (myGridView.BottomPagerRow == null)
return;
I have two TextBox on my page, and i want when a user fill one of them i warn him to fill another textbox, i mean to force user to fill all two textboxes or neither.
How to implement this using Validators, if applicable?
I added this controll on my page
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:RequiredFieldValidator ControlToValidate="txt1" Enabled="True" ID="required_validator1" runat="server" Text="Required" Visible="True" ValidationGroup="T"/>
<asp:TextBox ID="txt1" OnTextChanged="TextBox1_TextChanged" runat="server" AutoPostBack="True" />
<asp:RequiredFieldValidator ControlToValidate="txt2" Enabled="True" ID="required_validator2" runat="server" Text="Required" Visible="True" ValidationGroup="T" />
<asp:TextBox ID="txt2" CausesValidation="False" Enabled="False" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="T" OnClick="Button1_Click" />
and in my Webform.aspx.cs :
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
if (txt1.Text.Length > 0)
txt2.Enabled = true;
}
and :
protected void Button1_Click(object sender, EventArgs e)
{
if (txt1.Text == string.Empty && txt2.Text == string.Empty)
{
required_validator1.Enabled = false;
required_validator2.Enabled = false;
}
}
i want when user did not write any thing on txt1 and then he click on button, the validator warning does not show him an let him to resume,but it does not work, how can i do ti?
Use the logic. Set Required Field validator on both textboxes, and disable the second textbox. If user enters anything in the 1st textbox then enable 2nd textbox.
You can implement it using javascript. Simply set the textchange event of first textbox and check if its text length is greater than 1 then enable 2nd textbox.
ASPX:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:RequiredFieldValidator ControlToValidate="txt1" Enabled="True" ID="required_validator1" runat="server" Text="Required" Visible="True" />
<asp:TextBox ID="txt1" OnTextChanged="TextBox1_TextChanged" runat="server" />
<asp:RequiredFieldValidator ControlToValidate="txt2" Enabled="True" ID="required_validator2" runat="server" Text="Required" Visible="True" />
<asp:TextBox ID="txt2" CausesValidation="False" Enabled="False" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="txt1" EventName="TextChanged" />
</Triggers>
</asp:UpdatePanel>
C#:
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
if(txt1.Text.Length > 0)
txt2.Enabled = true;
}
How to get the AppId from gridView in codebehind, if I clicked the edit image button in second row.
Aspx Code:
<asp:BoundField HeaderText="AppId" DataField="AppID" />
<asp:TemplateField HeaderText="Actions" ControlStyle-Width="20px" ItemStyle-Width="130px">
<ItemTemplate>
<asp:ImageButton ID="imgMailCamp" runat="server" ImageUrl="~/Images/AppSetup/Mail.png"
Height="18px" ToolTip="Send Mail Campaign" CssClass="grdImageAlign" CommandName="SendMail" OnClick="btnMailCamp_Click" />
<asp:ImageButton ID="imgViewApp" runat="server" ImageUrl="~/Images/AppSetup/application-view-list-icon.png"
Height="18px" ToolTip="View Appplication" CssClass="grdImageAlign" CommandName="View" OnClick="btnView_Click" />
<asp:ImageButton ID="imgEditApp" runat="server" ImageUrl="~/Images/AppSetup/Action-edit-icon.png"
Height="18px" ToolTip="Edit Application" CssClass="grdImageAlign" CommandName="Edit" OnClick="btnEdit_Click"/>
<asp:ImageButton ID="imgDeleteApp" runat="server" ImageUrl="~/Images/AppSetup/Trash-can-icon.png"
Height="18px" ToolTip="Delete Application" CssClass="grdImageAlign" CommandName="Delete" OnClick="btnDelete_Click" />
</ItemTemplate>
</asp:TemplateField>
C# Code:
protected void btnEdit_Click(object sender, EventArgs e)
{
// I need to get the current row appId, I use this appId in next page for sql query
Response.Redirect("/Secured/EditApplication.aspx?AppID="+AppID);
}
Try Like this....Don't Define Click Event of Button....Define Button Like this...
<asp:ImageButton ID="imgEditApp" runat="server"
ImageUrl="~/Images/AppSetup/Action-edit-icon.png"
Height="18px" ToolTip="Edit Application" CssClass="grdImageAlign"
CommandName="Edit"/>
And
Define Your GridView RowEditing event Like this....
protected void gv_RowEditing(object sender, GridViewEditEventArgs e)
{
Response.Redirect("/Secured/EditApplication.aspx?AppID="+YourGridViewId.Rows[e.NewEditIndex].Cells[1].Text);
}
Edit:
I think you have problem in definig RowEditingEvent.....ok you can do this...nothing to change just write this code in you Click event...
protected void btnEdit_Click(object sender, EventArgs e)
{
ImageButton ib = sender as ImageButton;
GridViewRow row = ib.NamingContainer as GridViewRow;
Response.Redirect("/Secured/EditApplication.aspx?AppID="+YourGridViewId.Rows[row.RowIndex].Cells[1].Text);
}
Edit 2
<asp:ImageButton ID="imgEditApp" runat="server"
ImageUrl="~/Images/AppSetup/Action-edit-icon.png"
Height="18px" ToolTip="Edit Application" CssClass="grdImageAlign"
CommandName="Edit" CommandArgument='<%#Eval("AppID") %>'/>
protected void btnEdit_Click(object sender, EventArgs e)
{
string appid= (sender as ImageButton).CommandArgument;
Response.Redirect("/Secured/EditApplication.aspx?AppID="+appid
}
You can get grid view cell value from this.
GridView.Rows[RowIndex].Cells[CellIndex].Text
Here "RowIndex" is row number from which you want to get data and "CellIndex" is cell number from which you want to get data.
I think event "OnRowCommand" of gridview is best suited for your problem.
use blow link for more details
http://www.codeproject.com/Tips/564619/Example-of-gridview-rowcommand-on-Button-Click
it should be with commandargument
aspx
<asp:ImageButton ID="imgEditApp" CommandArgument='<%# Eval("AppID") %>' runat="server" ... OnClick="btnEdit_Click"/>
code
protected void gv_RowEditing(object sender, GridViewEditEventArgs e)
{
int categoryId = Convert.ToInt32(e.CommandArgument);
Response.Redirect("/Secured/EditApplication.aspx?AppID="+categoryId);
}
or u can use PostBackUrl property of imagebutton and it would be like this:
<asp:ImageButton ID="imgEditApp" PostBackUrl='<%# string.Format("/Secured/EditApplication.aspx?AppID={0}", Eval("AppID")) %>' runat="server" />
Check this code snippet.
This is the code in aspx file having two columns DataBound "AppId" and TemplateColumn "Action" containing Image Button. Observe CommandName and CommandArgument properties of Image Button. Also Define OnRowCommand Event listener for gridview.
<asp:GridView ID="grdDisplayData" runat="server" AutoGenerateColumns="false"
EnableViewState="false" onrowcommand="grdDisplayData_RowCommand">
<Columns>
<asp:BoundField HeaderText="AppId" DataField="AppId" />
<asp:TemplateField HeaderText="Action" >
<ItemTemplate>
<asp:Button ID="btnEdit" runat="server" Text="Edit" CommandName="MyEdit"
CommandArgument="<%# ((GridViewRow) Container).RowIndex%>"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ImageAction">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" Width="15px" Height="15px"
CommandName="ImgEdit" CommandArgument="<%# ((GridViewRow) Container).RowIndex%>"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
And here is the code behind code. The e.CommandArument returns the index of the row in which the image button was clicked.
protected void grdDisplayData_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
{
if (e.CommandName == "ImgEdit")
{
int RowIndex = Convert.ToInt32(e.CommandArgument);
Response.Redirect("/Secured/EditApplication.aspx?AppID=" + grdDisplayData.Rows[RowIndex].Cells[1].Text.Trim());
}
}
Let me know if this fixed your problem.
Cheers!!!
Piyush Deshpande
This is my grid
<asp:GridView ID="gridProduct" runat="server"
AutoGenerateColumns="false"
ShowFooter="true"
onrowcancelingedit="gridProduct_RowCancelingEdit"
onrowdeleting="gridProduct_RowDeleting" onrowediting="gridProduct_RowEditing"
onrowupdating="gridProduct_RowUpdating"
onrowcommand="gridProduct_RowCommand"
onrowdatabound="gridProduct_RowDataBound">
<Columns>
<asp:TemplateField>
<EditItemTemplate>
<asp:Button ID="buttonUpdate" CommandName="Update" runat="server" ToolTip="Update" Text="Update" />
<asp:Button ID="buttonCancel" CommandName="Cancel" runat="server" ToolTip="Cancel" Text="Cancel" />
</EditItemTemplate>
<ItemTemplate>
<asp:Button ID="buttonEdit" CommandName="Edit" runat="server" Text="Edit" ToolTip="Edit"/>
<asp:Button ID="buttonDelete" CommandName="Delete" runat="server" Text="Delete" ToolTip="Delete"/>
</ItemTemplate>
<FooterTemplate>
<asp:Button ID="buttonAdd" runat="server" Text="Ajouter" CommandName="AddNew" ToolTip="Add new User" ValidationGroup="validaiton" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="#Piece">
<EditItemTemplate>
<asp:Label ID="labelEditPiece" runat="server" Text='<%#Eval("Piece") %>'/>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="labelItemPiece" runat="server" Text='<%#Eval("Piece") %>'/>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="dropDownListPartsFooter" runat="server" DataTextField="Nom" DataValueField="ID_AchatTemplate">
</asp:DropDownList>
ControlToValidate="txtBoxPiece" Text="*" ValidationGroup="validaiton"/>--%>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Series">
<EditItemTemplate>
<asp:Label ID="labelEditSeries" runat="server" Text='<%#Eval("Series") %>'/>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="labelItemSeries" runat="server" Text='<%#Eval("Series") %>'/>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtBoxSeries" runat="server"/>
<asp:RequiredFieldValidator ID="fieldValidSeries" runat="server" ControlToValidate="txtBoxSeries" Text="*" ValidationGroup="validaiton"/>
</FooterTemplate>
.... </asp:TemplateField>
</Columns>
This is my page load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
PsaDataSet psaList = new PsaDataSet();
ViewState.Remove("psaList");
ViewState.Add("psaList", psaList);
ViewState.Add("psaUid", Guid.NewGuid());
if (psaList.PsaLink.DefaultView.Count == 0)
{
// Patch for view footer row when no data
PsaDataSet.PsaLinkDataTable tmpList = new PsaDataSet.PsaLinkDataTable();
PsaDataSet.PsaLinkRow tmpItem = tmpList.NewPsaLinkRow();
tmpItem.PsaUid = (Guid)ViewState["psaUid"];
tmpItem.PsaProductUid = Guid.Empty;
tmpItem.ProductId = 1;
tmpItem.Series = "test";
tmpItem.Rev = "test";
tmpItem.Firmware = "test";
tmpList.AddPsaLinkRow(tmpItem);
tmpList.AcceptChanges();
ViewState.Add("series", tmpItem.Series);
gridProduct.DataSource = tmpList;
gridProduct.DataBind();
}
}
else
{
//BindGrid((PsaDataSet)ViewState["psaList"], false);
}
}
private void BindGrid(PsaDataSet psaList, bool mustDataBind)
{
gridProduct.DataSource = psaList.PsaLink;
//if (mustDataBind)
//{
gridProduct.DataBind();
//}
}
This my onrowdatabound="gridProduct_RowDataBound"> method
protected void gridProduct_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["style"] = "display:none";
}
}
}
I want to add a condition (Based whit a test value inserted in page load) in the if(protected void gridProduct_RowDataBound method) for hiding just one time on page load??
Thank Frank!
I belive you can get the DataBoundItem from the row which is a type of "PsaDataSet.PsaLinkRow" and use that you get the ProductId, Series, etc. and do the condition that you require. Also, you have and if condition inside an if condition with the same condition for both. You only need one.