Click here to Skip to main content
15,913,287 members
Home / Discussions / C#
   

C#

 
GeneralRe: blocking the sql server 2000 Pin
Xmen Real 17-Feb-08 19:29
professional Xmen Real 17-Feb-08 19:29 
GeneralRe: blocking the sql server 2000 Pin
N a v a n e e t h17-Feb-08 21:54
N a v a n e e t h17-Feb-08 21:54 
GeneralRe: blocking the sql server 2000 Pin
Pete O'Hanlon17-Feb-08 22:06
mvePete O'Hanlon17-Feb-08 22:06 
GeneralRe: blocking the sql server 2000 Pin
Xmen Real 17-Feb-08 22:37
professional Xmen Real 17-Feb-08 22:37 
GeneralRe: blocking the sql server 2000 Pin
Pete O'Hanlon17-Feb-08 22:48
mvePete O'Hanlon17-Feb-08 22:48 
GeneralRe: blocking the sql server 2000 [modified] Pin
Xmen Real 17-Feb-08 22:59
professional Xmen Real 17-Feb-08 22:59 
GeneralRe: blocking the sql server 2000 Pin
SilimSayo18-Feb-08 9:46
SilimSayo18-Feb-08 9:46 
GeneralNested Grid View Probelm Pin
veereshIndia17-Feb-08 17:51
veereshIndia17-Feb-08 17:51 
Hi all,

Iam doing nested data grid operations iam facing a problem in that please help me on this


I have a gridview controls in asp.net page which is fetching data from data base then

RowDataBound of that data grid iam creating gridview dynamically i.e

means if there is 3 records in main gridview its creating 3 child gridview which has few data

i want to access the data of the child grid views but i can access only the last child grid views
data not all the child grid view data.i have attached my code here plase have a look on it.

protected void GridView_RowDataBound1(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.EmptyDataRow)
{
id++;
Int64 catId =Convert.ToInt64(e.Row.Cells[1].Text.ToString());
ds = new DataSet();
ds = objExitInterviewBLL.getQuestions(0, 'S', "", catId);
int count = 0;
if (ds.Tables[0].Rows.Count > 0)
{

NewDg = new GridView();
//NewDg= new GridView();


NewDg.ID = "NewDg" + id ;
txtHidden.Text = txtHidden.Text + "," + NewDg.ID;
NewDg.Attributes.Add("runat", "server");
NewDg.AutoGenerateColumns = false;

BoundField bc1 = new BoundField();
bc1.DataField = "Sno";
bc1.HeaderText = "Sno";
BoundField bc2 = new BoundField();
bc2.DataField = "Question";
bc2.HeaderText = "Question";
BoundField bc3 = new BoundField();
bc3.DataField = "Responsetp";
bc3.Visible = false;
TemplateField tc1 = new TemplateField();
tc1.ItemTemplate = new DataGridTemplate(ListItemType.Item, "Column1");
tc1.HeaderText = "Answers";
NewDg.Columns.Add(bc1);
NewDg.Columns.Add(bc2);
NewDg.Columns.Add(bc3);
NewDg.Columns.Add(tc1);
NewDg.DataSource = ds.Tables[0];
NewDg.DataBind();





while (ds.Tables[0].Rows.Count > count)
{
string question = ds.Tables[0].Rows[count]["Responsetp"].ToString();
if (string.Equals(question, "1"))
{
TextBox tx = (TextBox)(NewDg.Rows[count].Cells[3].FindControl("txt"));
tx.Visible = false;
DropDownList ddlList = (DropDownList)(NewDg.Rows[count].Cells[3].FindControl("ddl"));
ddlList.Visible = false;
TextBox txMultiline = (TextBox)(NewDg.Rows[count].Cells[3].FindControl("txtMultiline"));
txMultiline.Visible = false;
ListBox lst = (ListBox)(NewDg.Rows[count].Cells[3].FindControl("lst"));
Int64 tb032_id = Convert.ToInt64(NewDg.Rows[count].Cells[0].Text.ToString());
DataSet ds1 = objExitInterviewBLL.getListAnswers(0, 'S', "", tb032_id, 0);
if (ds1.Tables[0].Rows.Count > 0)
{
lst.DataSource = ds1;
lst.DataTextField = "Data_Text";
lst.DataBind();
}
else
{
lst.Visible = false;
}
}
else if (string.Equals(question, "0"))
{
DropDownList ddlList = (DropDownList)(NewDg.Rows[count].Cells[3].FindControl("ddl"));
ddlList.Visible = false;
TextBox tx = (TextBox)(NewDg.Rows[count].Cells[3].FindControl("txt"));
tx.Visible = true;
ListBox lst = (ListBox)(NewDg.Rows[count].Cells[3].FindControl("lst"));
lst.Visible = false;
TextBox txMultiline = (TextBox)(NewDg.Rows[count].Cells[3].FindControl("txtMultiline"));
txMultiline.Visible = false;


}
else if (string.Equals(question, "2"))
{

TextBox txMultiline = (TextBox)(NewDg.Rows[count].Cells[3].FindControl("txtMultiline"));
txMultiline.Visible = true;
TextBox tx = (TextBox)(NewDg.Rows[count].Cells[3].FindControl("txt"));
tx.Visible = false;

DropDownList ddlList = (DropDownList)(NewDg.Rows[count].Cells[3].FindControl("ddl"));
ddlList.Visible = false;
ListBox lst = (ListBox)(NewDg.Rows[count].Cells[3].FindControl("lst"));
lst.Visible = false;

}
count++;
}
NewDg.Height = Unit.Percentage(100.00);
SetProps(NewDg);
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw);
NewDg.RenderControl(htw);
string DivStart = "<DIV id='uniquename" + e.Row.RowIndex.ToString() + "' style='DISPLAY: none; HEIGHT: 100%;'>";
string DivBody = sw.ToString();
string DivEnd = "</DIV>";
string FullDIV = DivStart + DivBody + DivEnd;
int LastCellPosition = e.Row.Cells.Count - 1;
int NewCellPosition = e.Row.Cells.Count - 2;
e.Row.Cells[0].ID = "CellInfo" + e.Row.RowIndex.ToString();
if (ViewState["Mode"] != null && ViewState["Mode"].ToString() == "ShowDetails")
{
if (this.txtExpandedFields.Text.IndexOf(e.Row.Cells[0].ClientID) != -1)
{
//make it expand.
FullDIV = FullDIV.Replace("DISPLAY: none", "DISPLAY: block");
e.Row.Cells[0].Text = "<A>-</A>";
}
}

//match color
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[LastCellPosition].Text = e.Row.Cells[LastCellPosition].Text + "</td><tr><td bgcolor='f5f5f5'></td><td colspan='" + NewCellPosition + "'>" + FullDIV;
}
else
{
e.Row.Cells[LastCellPosition].Text = e.Row.Cells[LastCellPosition].Text + "</td><tr><td bgcolor='d3d3d3'></td><td colspan='" + NewCellPosition + "'>" + FullDIV;
}
e.Row.Cells[0].Attributes["onclick"] = "HideShowPanel('uniquename" + e.Row.RowIndex.ToString() + "'); ChangeHLText('" + e.Row.Cells[0].ClientID + "'); SetExpanded('" + e.Row.Cells[0].ClientID + "','" + txtExpandedFields.ClientID + "');";
e.Row.Cells[0].Attributes["onmouseover"] = "this.style.cursor='hand'";
e.Row.Cells[0].Attributes["onmouseout"] = "this.style.cursor='hand'";



}
}
}
catch (Exception ex)
{
}
finally
{
ds = null;

}

}


public class DataGridTemplate : ITemplate
{
ListItemType templateType;
string columnName;

public DataGridTemplate(ListItemType type, string colname)
{
templateType = type;
columnName = colname;
}
int id = 0;
public void InstantiateIn(System.Web.UI.Control container)
{
Literal lc = new Literal();
switch (templateType)
{

case ListItemType.Item:
DropDownList ddl = new DropDownList();
ddl.ID = "ddl";
ddl.Width = 100;
container.Controls.Add(ddl);
TextBox txt1 = new TextBox();
txt1.Width = 150;
txt1.ID = "txt";
container.Controls.Add(txt1);
ListBox lst1 = new ListBox();
lst1.Width = 100;
lst1.Height = 110;
lst1.ID = "lst";
container.Controls.Add(lst1);
TextBox txtMultiline = new TextBox();
txtMultiline.ID = "txtMultiline";
txtMultiline.Width = 200;
txtMultiline.Height = 60;
txtMultiline.Attributes.Add("textmode", "multiline");
container.Controls.Add(txtMultiline);
break;




}
}
}



protected void btnSave_Click(object sender, EventArgs e)
{
BindData();


string childGdIdList = txtHidden.Text.ToString();
string[] childGdId = childGdIdList.Split(new Char[] { ',' });
for (int i = 0; i < childGdId.Length; i++)
{
if (childGdId[i].ToString() != "")
{
string id = childGdId[i].ToString();
NewDg.ID = "NewDg" + i;

//NewDg.ID = "NewDg" + i;
for (int j = 0; j < NewDg.Rows.Count; j++)
{
string u = NewDg.Rows[j].Cells[0].Text.ToString();
}
}
}
}

private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
//clean up expanded records.
txtExpandedFields.Text = "";
//DataGrid1.CurrentPageIndex = e.NewPageIndex;
BindData();
}


public void BindData()
{
try
{
ds = new DataSet();
ds = objExitInterviewBLL.getCategory(0, 'A', "");
if (ds.Tables[0].Rows.Count > 0)
{
DataGrid1.DataSource = ds;
DataGrid1.DataBind();
}

}
catch (Exception ex)
{
}
finally
{
ds = null;
}

}

protected void Page_Load(object sender, EventArgs e)
{


if (!Page.IsPostBack)
{

BindData();

}
}

i want to join this group

QuestionFind node of binary tree Pin
help as an alias17-Feb-08 16:46
help as an alias17-Feb-08 16:46 
GeneralOn Screen Keyboard Pin
Jonathan Gibbs17-Feb-08 14:47
Jonathan Gibbs17-Feb-08 14:47 
GeneralRe: On Screen Keyboard Pin
Christian Graus17-Feb-08 16:40
protectorChristian Graus17-Feb-08 16:40 
QuestionRe: On Screen Keyboard Pin
Jonathan Gibbs18-Feb-08 8:45
Jonathan Gibbs18-Feb-08 8:45 
GeneralRe: On Screen Keyboard Pin
PIEBALDconsult18-Feb-08 9:54
mvePIEBALDconsult18-Feb-08 9:54 
GeneralRe: On Screen Keyboard Pin
Jonathan Gibbs18-Feb-08 13:23
Jonathan Gibbs18-Feb-08 13:23 
GeneralRe: On Screen Keyboard Pin
PIEBALDconsult18-Feb-08 16:15
mvePIEBALDconsult18-Feb-08 16:15 
GeneralRe: On Screen Keyboard Pin
Jonathan Gibbs19-Feb-08 1:13
Jonathan Gibbs19-Feb-08 1:13 
GeneralEnding EXCEL.EXE process from C# and EXCEL COM interface. Pin
mjdesnoyer17-Feb-08 8:04
mjdesnoyer17-Feb-08 8:04 
GeneralRe: Ending EXCEL.EXE process from C# and EXCEL COM interface. Pin
Jimmanuel17-Feb-08 10:32
Jimmanuel17-Feb-08 10:32 
GeneralJava to C# conversion Pin
james_dixon_200817-Feb-08 7:54
james_dixon_200817-Feb-08 7:54 
GeneralRe: Java to C# conversion Pin
Paul Conrad17-Feb-08 7:59
professionalPaul Conrad17-Feb-08 7:59 
GeneralRe: Java to C# conversion Pin
Pete O'Hanlon17-Feb-08 10:39
mvePete O'Hanlon17-Feb-08 10:39 
Generaltext box issues Pin
cmandy17-Feb-08 7:30
cmandy17-Feb-08 7:30 
GeneralRe: text box issues Pin
Gareth H17-Feb-08 8:52
Gareth H17-Feb-08 8:52 
GeneralRe: text box issues Pin
cmandy17-Feb-08 9:28
cmandy17-Feb-08 9:28 
GeneralRe: text box issues Pin
Christian Graus17-Feb-08 10:00
protectorChristian Graus17-Feb-08 10:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.