473,385 Members | 1,707 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,385 software developers and data experts.

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_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.EditItem)
{

if(lstTypes.Items[i].Text == "System.Boolean")
{
TextBox tb=(TextBox)e.Item.Cells[i+3].Controls[0];
string s=tb.Text.ToLower();
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 1163
you could also have a template column in the HTML between your
<asp:DataGrid> tabs

<asp:TemplateColumn>
<HeaderStyle Wrap="False"></HeaderStyle>
<HeaderTemplate>
<asp:CheckBox id="CheckAll" OnClick="javascript: return
select_deselectAll (this.checked, this.id);"
runat="server" AutoPostBack="False" ToolTip="Select/Deselect
All" />Read
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ToolTip="Mark this item as read, click 'Refresh' to
change visible 'Status'." id="CheckBoxCompleted"
Runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>

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

private void ButtonRefresh_Click(object sender, System.EventArgs e)
{

foreach ( DataGridItem dataitem in DataGridLog.Items )
{
// if it's checked
if (
((CheckBox)(dataitem.FindControl("CheckBoxComplete d"))).Checked )
{
// get the line id that this item is clicked on

// change your data set according
}
}

BindGrid();
}
"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:52**********************************@microsof t.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_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.EditItem)
{

if(lstTypes.Items[i].Text == "System.Boolean")
{
TextBox tb=(TextBox)e.Item.Cells[i+3].Controls[0];
string s=tb.Text.ToLower();
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
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...
2
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...
3
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,...
4
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. ...
0
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...
5
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...
14
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...
4
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...
9
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...
10
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.