473,804 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid Help!

Dear:

I have DataGrid , which its task to (Edit, update, and delete) contents of
XML File.

the structure of XML like this

<Info>
<Name></Name>
<Age></Age>
<Date_OB></Date_OB>
<CStatus></CStatus>
<BStatus></BStatus>
<DStatus></DStatus>
</Info>

in XSD the CStatus,BStatus ,DStatus ( are boolean type), the case that when
user click Edit in datagrid anywhere there boolean type to be replaced by
CheckBox(I achieved this task on ItemDataBound by check the column type and
add CheckBox Control to cell and remove the TextBox) .
but the problem when doing updates how can I retrieve the Dyamically Created
Check Box Values to update the XML.

[code] for how I can display the checkbox
private void DataGrid1_ItemD ataBound(object sender,
System.Web.UI.W ebControls.Data GridItemEventAr gs e)
{
if(e.Item.ItemT ype == ListItemType.Ed itItem)
{

if(lstTypes.Ite ms[i].Text == "System.Boolean ")
{
TextBox tb=(TextBox)e.I tem.Cells[i+3].Controls[0];
string s=tb.Text.ToLow er();
e.Item.Cells[i+3].Text="<INPUT id='chkBool' type='checkbox' >";

}
}
}

now I need when check/uncheck the checkbox and do updates to take all
updates on all checkbox value in datagrid and save thier states.
How can I achieve that.

Regards
Nov 18 '05 #1
2 1182
you could also have a template column in the HTML between your
<asp:DataGrid > tabs

<asp:TemplateCo lumn>
<HeaderStyle Wrap="False"></HeaderStyle>
<HeaderTemplate >
<asp:CheckBox id="CheckAll" OnClick="javasc ript: return
select_deselect All (this.checked, this.id);"
runat="server" AutoPostBack="F alse" ToolTip="Select/Deselect
All" />Read
</HeaderTemplate>
<ItemTemplate >
<asp:CheckBox ToolTip="Mark this item as read, click 'Refresh' to
change visible 'Status'." id="CheckBoxCom pleted"
Runat="server"> </asp:CheckBox>
</ItemTemplate>
</asp:TemplateCol umn>

Then the "Refresh" button that the tooltip on the checkbox refers to has the
following event handler...

private void ButtonRefresh_C lick(object sender, System.EventArg s e)
{

foreach ( DataGridItem dataitem in DataGridLog.Ite ms )
{
// if it's checked
if (
((CheckBox)(dat aitem.FindContr ol("CheckBoxCom pleted"))).Chec ked )
{
// get the line id that this item is clicked on

// change your data set according
}
}

BindGrid();
}
"Raed Sawalha" <Ra*********@di scussions.micro soft.com> wrote in message
news:52******** *************** ***********@mic rosoft.com...
Dear:

I have DataGrid , which its task to (Edit, update, and delete) contents of
XML File.

the structure of XML like this

<Info>
<Name></Name>
<Age></Age>
<Date_OB></Date_OB>
<CStatus></CStatus>
<BStatus></BStatus>
<DStatus></DStatus>
</Info>

in XSD the CStatus,BStatus ,DStatus ( are boolean type), the case that when
user click Edit in datagrid anywhere there boolean type to be replaced by
CheckBox(I achieved this task on ItemDataBound by check the column type
and
add CheckBox Control to cell and remove the TextBox) .
but the problem when doing updates how can I retrieve the Dyamically
Created
Check Box Values to update the XML.

[code] for how I can display the checkbox
private void DataGrid1_ItemD ataBound(object sender,
System.Web.UI.W ebControls.Data GridItemEventAr gs e)
{
if(e.Item.ItemT ype == ListItemType.Ed itItem)
{

if(lstTypes.Ite ms[i].Text == "System.Boolean ")
{
TextBox tb=(TextBox)e.I tem.Cells[i+3].Controls[0];
string s=tb.Text.ToLow er();
e.Item.Cells[i+3].Text="<INPUT id='chkBool' type='checkbox'
>";


}
}
}

now I need when check/uncheck the checkbox and do updates to take all
updates on all checkbox value in datagrid and save thier states.
How can I achieve that.

Regards

Nov 18 '05 #2
If you had a checkbox always in that column but make its visible
property TRUE/FALSE in item_created or item_bound, you can get it
working as you want.
Nov 18 '05 #3

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

Similar topics

3
3058
by: Stephen | last post by:
I've got a datagrid with a remove button and I would like to add some code in the code behind page so as whenthe button is clicked the corresponding row in the datagrid is removed. The Datagrid is populated by the items in an arraylist shown in the code below. When the button is clicked I would also like the code to remove the items from the Arraylist. I've very little experience working with datagrids and arraylists so im finding this...
2
9931
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell (multi-select without modifier keys). I got that working fine, but I also wanted to keep rows selected after a sort, which I do by storing the row's id in an arraylist. The idea was to do the sort and then go back and re-select the rows with that...
3
5048
by: Ryan Liu | last post by:
Hi there, I got a NullReferenceException when delete last row in a datagrid. I had hard time to solve since it does not occur in my own code. I put a datagrid in my inherited user control, then put this control on a form. I use DataAdaptor to fill the data table and update database.
4
5360
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. Currently everything is working. I can find the updated rows/columns by parsing the posted data collection against the DataGrid DataSource. However, when there is a large amount of DataGridItems (rows) the update processing can take a while. ...
0
1707
by: optimizeit | last post by:
What I am attempting to do is import an Excel Workbook and display the worksheets in a datagrid dynamically. I am very close to getting this to work. I have to this point successfully imported a single worksheet into a dataset. I successfully built a dynamic datagrid. And I did successfully bind it to the dataset. Then I added the datagrid control to a PlaceHolder. The first worksheet displays beautifully. The next step is to allow...
5
5915
by: Genojoe | last post by:
I am using code from Help with two exceptions. (1) I increased the number of sample rows from 3 to 20, and (2) I anchored the datagrid to bottom of form so that I can change the size of the grid by changing the size of the form The code is at the following location in the January, 2004 help ms-help://MS.VSCC.2003/MS.MSDNQTR.2004JAN.1033/cpref/html/frlrfSystemWindowsFormsDataGridClassTopic.ht You can also find it by doing a search for...
14
1846
by: Brett Sinclair | last post by:
Hello everybody I'm still on the learning curve here...and from what I read, I created inherited datagrid class so I could have icons, combobox...etc in the columns of my datagrid. The grid will be used to populate information coming from a Webservice. (No datasets - No datareaders). So, I do not know see how to use the "datasource".
4
2141
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a Delete button on the end of each row. I am unable to gain access to the event when the button is clicked. I don't fully understand how the click gets connected to the C# code,
9
2734
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the code: <script runat="server"> Dim sqlConn As New SqlConnection(".....") Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If Not (Page.IsPostBack) Then FillDataGrid()
10
2976
by: amiga500 | last post by:
Hello, I have one basic simple question. When I have multiple records in the datagrid as follows: Code Product 1 Product 2 Product 3 11111 A B C 22222 D E F 33333 G H I 44444 J K L
0
9715
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10603
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10353
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10099
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3003
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.