473,387 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DATAGRID SETTING VISIBILITY of CONTROLS on RUN TIME.

Dear ALL,
I am facing a bit problem in DATAGRID. so may be you guys can help me
out.
Actually on a DataGrid I am having following controls:
1) 2 DropDown Menu
2) 1 Text Box
3) 1 ADD Button
4) 1 Remove Button

So these all controls are in 1 row and looks like:

DROPDOWN1 DROPDOWN2 TEXTBOX ADD BUTTON REMOVE BUTTON.

So when user will press ADD Button then the same new row will be
populated and will look like.

DROPDOWN1 DROPDOWN2 TEXTBOX ADD BUTTON REMOVE BUTTON
(ROW1)
DROPDOWN1 DROPDOWN2 TEXTBOX ADD BUTTON REMOVE BUTTON
(ROW2)

And So on. So these rows will be populated until user press ADD BUTTON.
and similarly on pressing the REMOVE BUTTON the corresponding ROW will
be deleted.

I have implemented this functionality. but NOW the REAL PROBLEM comes
into picture.

Actually, when this SECOND ROW (ROW 2 and so on) will be populated
then I have to set the VISIBILITY of ADD BUTTON of FIRST ROW (or
previous row) to FALSE.

SO LOGICALLY SPEAKING this ADD Button should be visible only for the
CURRENT ROW and for all the previous rows the ADD BUTTON's TEXT should
be replaced by a LABEL Control.

I tried to access this BUTTON CONTROL a lot but was unable to do that.

So if you have any idea then please let me know. I am posting the code
for your review. Your help is really appreciated.
public void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
dsSource.Tables.Add(new DataTable("RepeaterSource"));
dsSource.Tables[0].Columns.Add(new DataColumn("DropDownValue2"));
dsSource.Tables[0].Columns.Add(new DataColumn("EditBoxValue"));
dsSource.Tables[0].Rows.Add(new Object[] { 2,""});
datagrid1.DataSource = dsSource;
datagrid1.DataMember = "RepeaterSource";
datagrid1.DataBind();

Session[DATA_SOURCE_KEY] = dsSource;
}
else
{
dsSource = (DataSet)Session[DATA_SOURCE_KEY];
datagrid1.DataSource = dsSource;
datagrid1.DataMember = "RepeaterSource";
}
}

public void OnItemCommand(Object sender, DataGridCommandEventArgs e)
{
Label lLabel = new Label();
if(e.CommandName == "Add")
dsSource.Tables[0].Rows.Add(new object[] {1,"Text Here" });
dsSource.Tables[0].Rows[e.Item.ItemIndex-1][3].ToString = "tEXT";
datagrid1.DataBind();
Session[DATA_SOURCE_KEY] = dsSource;
}
if(e.CommandName =="Delete")
{
dsSource.Tables[0].Rows[e.Item.ItemIndex].Delete();
datagrid1.DataBind();
Session[DATA_SOURCE_KEY] = dsSource;
}
}


HERE IS THE CODE BEHIND PAGE:`
<asp:datagrid id="datagrid1" runat="server" Width="288px"
GridLines="Vertical" Font-Size="8pt"
Font-Name="verdana" Cellpadding="3" AutoGenerateColumns="False"
ShowFooter="True" BorderWidth="1px" BorderColor="#999999"
BackColor="White" Font-Names="verdana" BorderStyle="None"
OnItemCommand="OnItemCommand" <Columns>
<asp:TemplateColumn>
<ItemTemplate>
` <asp:DropDownList Runat="server" ID="comparatorDropDown" >
<asp:ListItem Value="2" Text="Select Comparator"
lected="True"></asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:DropDownList id="Dropdownlist1" runat="server" >
<asp:ListItem Value="citigroup_cfo">CitiGroup_Cfo</asp:ListItem>
<asp:ListItem Value="citigroup_cf1">CitiGroup_Cf1</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:TextBox id="Textbox1" runat="server" Columns="20" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Label Runat="server" ID="Label1"
Visible="true">AND</asp:Label </ItemTemplate>
<FooterTemplate>
<asp:Button Text="Add Condition" Font-Size="10px" runat="server"
ID="AddButton" CommandName="Add" Width="100%" />
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button runat="Server" Text="Remove Condition"
ID="RemoveButton" CommandName="Delete" Width="100%" Font-Size="10px" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

Nov 13 '06 #1
0 1209

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
1
by: Micky Pearce | last post by:
Hi I have a page containing a hidden <div> called 'controls' plus an <iframe> containing a second page. I need to be able to set the visibility of the 'controls' div when the page in the iframe...
5
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. ...
1
by: Jim Heavey | last post by:
I have a datagrid and there are 2 columns where I may or may not want to print based upon a condition. I thought I could use the OnItemCreated Event and then turn the visibility flag on or off as...
2
by: tshad | last post by:
I have a datagrid that has objects that are not visible and I need to use them in my Sql Statement. The problem is they are not there when set as "visible=false", but they are if set to true. ...
4
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a...
2
by: | last post by:
Is it possible to use IE transition effects (e.g. progid:DXImageTransform.Microsoft.Fade(Duration=2)">) to smooth "classic" (IE non-ATLAS) datagrid paging? How do you wire up the transition effect...
7
by: GaryDean | last post by:
(one of our developers posted this and it got no answer so I'm giving it another try) I'm converting a DataGrid utility component that previously used the columns array to function as it has in...
2
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor information and the details loads the documents for that vendor in a datagrid. Everything is working fine until I click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.