DataGrid Help!

G

Guest

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
 
D

Dan =o\)

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("CheckBoxCompleted"))).Checked )
{
// get the line id that this item is clicked on

// change your data set according
}
}

BindGrid();
}


Raed Sawalha said:
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'[QUOTE]
";[/QUOTE]

}
}
}

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[/QUOTE]
 
P

Piyush Bhatt

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top