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

datagrid

I'm trying to list my data into my datagrid creating stored procedures in
oracle db..My data includes questions for a survey....It's simple but i cant
see my datagrid in my web form..I'm now going to send all my codes...Please
help me finding an exact solution...

private void Page_Load(object sender, System.EventArgs e)
{
if (Page.IsPostBack)
return;

if (Request.QueryString["centerId"]!=null)
bindMySurvey(Int32.Parse(Request.QueryString["centerId"].ToString()));

}

private void bindMySurvey(int centerId)
{
coreMarseg.clinicalTrials mySurvey = new coreMarseg.clinicalTrials();
coreMarseg.Units myUnit = new coreMarseg.Units();

DataSet myDataSet = mySurvey.getSurvey(centerId);

comboCenterName.DataSource =
myUnit.getUnitName(Int32.Parse(Request.QueryString["centerId"].ToString()));
comboCenterName.DataTextField = "UNIT_NAME";
comboCenterName.DataValueField = "UNIT_ID";
comboCenterName.DataBind();
textRowId.Text = myDataSet.Tables[0].Rows[0]["ROWID"].ToString();
comboCenterName.SelectedIndex =
comboCenterName.Items.IndexOf(comboCenterName.Item s.FindByValue(myDataSet.Tables[0].Rows[0]["S_CENTER_ID"].ToString()));
textCenterResponsible.Text =
myDataSet.Tables[0].Rows[0]["S_CENTER_RESPONSIBLE"].ToString();
textCenterResponsibleTitle.Text =
myDataSet.Tables[0].Rows[0]["S_CENTER_RESPONSIBLE_TITLE"].ToString();
textCenterResResponsibility.Text =
myDataSet.Tables[0].Rows[0]["S_CENTER_RES_RESPONSIBILITY"].ToString();

bindMyDataGrid(Int32.Parse(Request.QueryString["centerId"].ToString()),
Int32.Parse(Request.QueryString["questionId"].ToString()));

}

private void bindMyDataGrid(int centerId, int questionId)
{
coreMarseg.clinicalTrials mySurvey = new coreMarseg.clinicalTrials();

myDataGrid.DataSource = mySurvey.getSurveyDetail(centerId, questionId);
myDataGrid.DataBind();
}

private void Save_Click(object sender, System.EventArgs e)
{
this.Validate();

if (Page.IsValid)
{
coreMarseg.clinicalTrials mySurvey = new coreMarseg.clinicalTrials();

if ((Request.QueryString["centerId"]==null) ||
(Request.QueryString["centerId"]==""))
{
if (mySurvey.addSurvey(comboCenterName.SelectedItem.V alue,
textCenterResponsible.Text,
textCenterResponsibleTitle.Text, textCenterResResponsibility.Text))
{
myError.Visible = false;
}
else
{
myError.Visible = true;
((Label)myError.FindControl("labelError")).Text =
mySurvey.myError.getLastError();
}
}
}
---------------
<asp:datagrid id="myDataGrid" runat="server" Font-Size="Smaller"
Font-Names="Verdana" Width="979px"
AllowSorting="True" CellPadding="1" CellSpacing="1"
AutoGenerateColumns="False" BorderColor="Gray">
<SelectedItemStyle CssClass="selectedGridRow"></SelectedItemStyle>
<EditItemStyle CssClass="defaultGridEditItem"></EditItemStyle>
<AlternatingItemStyle
CssClass="defaultGridAlternatingRow"></AlternatingItemStyle>
<ItemStyle CssClass="defaultGridRow"></ItemStyle>
<HeaderStyle CssClass="defaultGridHeader"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Questions">
<HeaderStyle HorizontalAlign="Center" Width="400px"></HeaderStyle>
<ItemStyle HorizontalAlign="Left" Width="400px"></ItemStyle>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,"QUESTION_DESC" )%>
<asp:TextBox id="textQuestionId" runat="server" Visible="False"
Text='<%# DataBinder.Eval(Container.DataItem,"QUESTION_ID")% >'>
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Yes">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:CheckBox id="cbYes" Checked="True"
runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="No">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:CheckBox id="cbNo" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Comments">
<HeaderStyle HorizontalAlign="Center" Width="50px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="50px"></ItemStyle>
<ItemTemplate>
<asp:Textbox id="textComment" runat="server"
CssClass="defaultTextItemLeft" Width="400" MaxLength="1024"
TextMode="MultiLine" Rows="1"></asp:Textbox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

----------------

public DataSet getSurvey (int centerId)

{

OracleConnection myConnection = new
OracleConnection(myRegistry.getRegistryValue("conn ectionString"));

myConnection.Open();

OracleCommand myCommand = myConnection.CreateCommand();

myCommand.CommandText = "MEDICAL.TRIALS_PKG.GET_SURVEY";

myCommand.CommandType = CommandType.StoredProcedure;

myCommand.Parameters.Add(new OracleParameter("resultset",
OracleType.Cursor)).Direction = ParameterDirection.Output;

OracleDataAdapter adapter = new OracleDataAdapter(myCommand);

myCommand.Parameters.Add("p_s_center_id", OracleType.Number).Value = centerId;

DataSet myDataSet = new DataSet();

adapter.Fill(myDataSet);

myConnection.Close();

return myDataSet;

}

public DataSet getSurveyDetail (int centerId, int questionId)

{

OracleConnection myConnection = new
OracleConnection(myRegistry.getRegistryValue("conn ectionString"));

myConnection.Open();

OracleCommand myCommand = myConnection.CreateCommand();

myCommand.CommandText = "MEDICAL.TRIALS_PKG.GET_SURVEY_DETAIL";

myCommand.CommandType = CommandType.StoredProcedure;

myCommand.Parameters.Add(new OracleParameter("resultset",
OracleType.Cursor)).Direction = ParameterDirection.Output;

myCommand.Parameters.Add("p_sd_center_id", OracleType.Number).Value =
centerId;

myCommand.Parameters.Add("p_sd_question_id", OracleType.Number).Value =
questionId;
OracleDataAdapter adapter = new OracleDataAdapter(myCommand);

DataSet myDataSet = new DataSet();

adapter.Fill(myDataSet);

myConnection.Close();

return myDataSet;

}

------------------------------------------

procedure GET_SURVEY (resultset out globals.resultset, p_s_center_id in
number)
is
begin

open resultset for
select S_CENTER_ID, S_CENTER_RESPONSIBLE, S_CENTER_RESPONSIBLE_TITLE,
S_CENTER_RES_RESPONSIBILITY
from MEDICAL.SURVEY
where S_CENTER_ID = p_s_center_id;

end;
---------------------------

procedure GET_SURVEY_DETAIL(resultset out globals.resultset, p_sd_center_id
in number)
is

begin
open resultset for

select * from MEDICAL.SURVEY_DETAIL

where SD_CENTER_ID = sd_center_id

order by SD_CENTER_ID, SD_QUESTION_ID;

end;
Nov 16 '05 #1
1 3749
Bind a Table or DefaultView in DataGrid from getSurveyDetail DataSet instead
of binding DataSet.

--
Regards,
Amal
http://geocities.com/techsharing
"aylin_sk" wrote:
I'm trying to list my data into my datagrid creating stored procedures in
oracle db..My data includes questions for a survey....It's simple but i cant
see my datagrid in my web form..I'm now going to send all my codes...Please
help me finding an exact solution...

private void Page_Load(object sender, System.EventArgs e)
{
if (Page.IsPostBack)
return;

if (Request.QueryString["centerId"]!=null)
bindMySurvey(Int32.Parse(Request.QueryString["centerId"].ToString()));

}

private void bindMySurvey(int centerId)
{
coreMarseg.clinicalTrials mySurvey = new coreMarseg.clinicalTrials();
coreMarseg.Units myUnit = new coreMarseg.Units();

DataSet myDataSet = mySurvey.getSurvey(centerId);

comboCenterName.DataSource =
myUnit.getUnitName(Int32.Parse(Request.QueryString["centerId"].ToString()));
comboCenterName.DataTextField = "UNIT_NAME";
comboCenterName.DataValueField = "UNIT_ID";
comboCenterName.DataBind();
textRowId.Text = myDataSet.Tables[0].Rows[0]["ROWID"].ToString();
comboCenterName.SelectedIndex =
comboCenterName.Items.IndexOf(comboCenterName.Item s.FindByValue(myDataSet.Tables[0].Rows[0]["S_CENTER_ID"].ToString()));
textCenterResponsible.Text =
myDataSet.Tables[0].Rows[0]["S_CENTER_RESPONSIBLE"].ToString();
textCenterResponsibleTitle.Text =
myDataSet.Tables[0].Rows[0]["S_CENTER_RESPONSIBLE_TITLE"].ToString();
textCenterResResponsibility.Text =
myDataSet.Tables[0].Rows[0]["S_CENTER_RES_RESPONSIBILITY"].ToString();

bindMyDataGrid(Int32.Parse(Request.QueryString["centerId"].ToString()),
Int32.Parse(Request.QueryString["questionId"].ToString()));

}

private void bindMyDataGrid(int centerId, int questionId)
{
coreMarseg.clinicalTrials mySurvey = new coreMarseg.clinicalTrials();

myDataGrid.DataSource = mySurvey.getSurveyDetail(centerId, questionId);
myDataGrid.DataBind();
}

private void Save_Click(object sender, System.EventArgs e)
{
this.Validate();

if (Page.IsValid)
{
coreMarseg.clinicalTrials mySurvey = new coreMarseg.clinicalTrials();

if ((Request.QueryString["centerId"]==null) ||
(Request.QueryString["centerId"]==""))
{
if (mySurvey.addSurvey(comboCenterName.SelectedItem.V alue,
textCenterResponsible.Text,
textCenterResponsibleTitle.Text, textCenterResResponsibility.Text))
{
myError.Visible = false;
}
else
{
myError.Visible = true;
((Label)myError.FindControl("labelError")).Text =
mySurvey.myError.getLastError();
}
}
}
---------------
<asp:datagrid id="myDataGrid" runat="server" Font-Size="Smaller"
Font-Names="Verdana" Width="979px"
AllowSorting="True" CellPadding="1" CellSpacing="1"
AutoGenerateColumns="False" BorderColor="Gray">
<SelectedItemStyle CssClass="selectedGridRow"></SelectedItemStyle>
<EditItemStyle CssClass="defaultGridEditItem"></EditItemStyle>
<AlternatingItemStyle
CssClass="defaultGridAlternatingRow"></AlternatingItemStyle>
<ItemStyle CssClass="defaultGridRow"></ItemStyle>
<HeaderStyle CssClass="defaultGridHeader"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Questions">
<HeaderStyle HorizontalAlign="Center" Width="400px"></HeaderStyle>
<ItemStyle HorizontalAlign="Left" Width="400px"></ItemStyle>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,"QUESTION_DESC" )%>
<asp:TextBox id="textQuestionId" runat="server" Visible="False"
Text='<%# DataBinder.Eval(Container.DataItem,"QUESTION_ID")% >'>
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Yes">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:CheckBox id="cbYes" Checked="True"
runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="No">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:CheckBox id="cbNo" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Comments">
<HeaderStyle HorizontalAlign="Center" Width="50px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" Width="50px"></ItemStyle>
<ItemTemplate>
<asp:Textbox id="textComment" runat="server"
CssClass="defaultTextItemLeft" Width="400" MaxLength="1024"
TextMode="MultiLine" Rows="1"></asp:Textbox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

----------------

public DataSet getSurvey (int centerId)

{

OracleConnection myConnection = new
OracleConnection(myRegistry.getRegistryValue("conn ectionString"));

myConnection.Open();

OracleCommand myCommand = myConnection.CreateCommand();

myCommand.CommandText = "MEDICAL.TRIALS_PKG.GET_SURVEY";

myCommand.CommandType = CommandType.StoredProcedure;

myCommand.Parameters.Add(new OracleParameter("resultset",
OracleType.Cursor)).Direction = ParameterDirection.Output;

OracleDataAdapter adapter = new OracleDataAdapter(myCommand);

myCommand.Parameters.Add("p_s_center_id", OracleType.Number).Value = centerId;

DataSet myDataSet = new DataSet();

adapter.Fill(myDataSet);

myConnection.Close();

return myDataSet;

}

public DataSet getSurveyDetail (int centerId, int questionId)

{

OracleConnection myConnection = new
OracleConnection(myRegistry.getRegistryValue("conn ectionString"));

myConnection.Open();

OracleCommand myCommand = myConnection.CreateCommand();

myCommand.CommandText = "MEDICAL.TRIALS_PKG.GET_SURVEY_DETAIL";

myCommand.CommandType = CommandType.StoredProcedure;

myCommand.Parameters.Add(new OracleParameter("resultset",
OracleType.Cursor)).Direction = ParameterDirection.Output;

myCommand.Parameters.Add("p_sd_center_id", OracleType.Number).Value =
centerId;

myCommand.Parameters.Add("p_sd_question_id", OracleType.Number).Value =
questionId;
OracleDataAdapter adapter = new OracleDataAdapter(myCommand);

DataSet myDataSet = new DataSet();

adapter.Fill(myDataSet);

myConnection.Close();

return myDataSet;

}

------------------------------------------

procedure GET_SURVEY (resultset out globals.resultset, p_s_center_id in
number)
is
begin

open resultset for
select S_CENTER_ID, S_CENTER_RESPONSIBLE, S_CENTER_RESPONSIBLE_TITLE,
S_CENTER_RES_RESPONSIBILITY
from MEDICAL.SURVEY
where S_CENTER_ID = p_s_center_id;

end;
---------------------------

procedure GET_SURVEY_DETAIL(resultset out globals.resultset, p_sd_center_id
in number)
is

begin
open resultset for

select * from MEDICAL.SURVEY_DETAIL

where SD_CENTER_ID = sd_center_id

order by SD_CENTER_ID, SD_QUESTION_ID;

end;

Nov 17 '05 #2

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

Similar topics

2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
0
by: Richard Ryerson | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls (watch...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
7
by: Dave | last post by:
Are there any add-on products or samples available that can do the following in an vb.net datagrid I want to compare 2 rows in a datagrid - one row from one database and another row for another...
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...
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...
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
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...
0
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...
0
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...

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.