TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
aylin_sk
NA
87
0
To bind to Datagrids
Jan 7 2005 3:40 AM
How can i bind 2 datagrids that have checkboxes in the first columns??When i checked one row from first datagrid and then checked a row from second datagrid , i should insert selected rows into the database....Please help me and correct my code... private void Page_Load(object sender, System.EventArgs e) { if (Page.IsPostBack) return; if (Request.QueryString["hemPatientId"]!=null) bindMyHemogram(Int32.Parse(Request.QueryString["hemPatientId"].ToString())); } private void bindMyHemogram(int hemPatientId) { coreLpms.hemograms myHemogram = new coreLpms.hemograms(); DataSet myDataSet = myHemogram.getPatientsHemogram(hemPatientId); if (myDataSet.Tables[0].Rows[0]["HEM_HEMOGRAMDATE"]==DBNull.Value) textHemHemogramDate.Text = ""; else textHemHemogramDate.Text = Convert.ToDateTime(myDataSet.Tables[0].Rows[0]["HEM_HEMOGRAMDATE"]).ToString("dd-MM-yyyy"); textHemLokosit.Text = myDataSet.Tables[0].Rows[0]["HEM_LOKOSIT"].ToString(); textHemNNS.Text = myDataSet.Tables[0].Rows[0]["HEM_NNS"].ToString(); textHemEOS.Text = myDataSet.Tables[0].Rows[0]["HEM_EOS"].ToString(); textHemBAS.Text = myDataSet.Tables[0].Rows[0]["HEM_BAS"].ToString(); textHemLIM.Text = myDataSet.Tables[0].Rows[0]["HEM_LIM"].ToString(); textHemMON.Text = myDataSet.Tables[0].Rows[0]["HEM_MON"].ToString(); textHemDoze.Text = myDataSet.Tables[0].Rows[0]["HEM_DOZE"].ToString(); textHemPack1.Text = myDataSet.Tables[0].Rows[0]["HEM_PACK1"].ToString(); textHemPack2.Text = myDataSet.Tables[0].Rows[0]["HEM_PACK2"].ToString(); bindMyPhysicianGrid(Request.QueryString["customerType"].ToString(), Int32.Parse(Request.QueryString["seperationId"].ToString()), Request.QueryString["fullname"].ToString()); bindMyPharmaCistGrid(Request.QueryString["customerType"].ToString(), Int32.Parse(Request.QueryString["seperationId"].ToString()), Request.QueryString["fullname"].ToString()); } private void bindMyPhysicianGrid(string customerType, int seperationId, string fullname) { coreMarseg.Customers myCustomer = new coreMarseg.Customers(); myPhysicianGrid.DataSource = myCustomer.getCustomersBySeperation("Y", 0, physicianFullName.Text); myPhysicianGrid.DataBind(); } private void bindMyPharmaCistGrid(string customerType, int seperationId, string fullname) { coreMarseg.Customers myCustomer = new coreMarseg.Customers(); myPharmaCistGrid.DataSource = myCustomer.getCustomersBySeperation("Y", 0, pharmaCistFullName.Text); myPharmaCistGrid.DataBind(); } private void Button_Click(object sender, System.EventArgs e) { coreLpms.hemograms myHemogram = new coreLpms.hemograms(); coreMarseg.Customers myCustomer = new coreMarseg.Customers(); DataGridItem myItem; for(int i=0;i < myPhysicianGrid.Items.Count; i++) { myItem = myPhysicianGrid.Items[i]; if ((myItem.ItemType != ListItemType.Header) && (myItem.ItemType != ListItemType.Footer) && (myItem.ItemType != ListItemType.Separator)) { if (((CheckBox)myItem.FindControl("cbSelectRow1")).Checked==true) { if (myHemogram.addHemogram(textHemHemogramDate.Text, textHemLokosit.Text, textHemNNS.Text, textHemEOS.Text, textHemBAS.Text, textHemLIM.Text, textHemMON.Text, textHemDoze.Text, textHemPack1.Text, textHemPack2.Text)) { myError.Visible = false; this.Response.Redirect("patient.aspx?patientNumber=" + Request.QueryString["patientNumber"].ToString()); bindMyHemogram(Int32.Parse(Request.QueryString["hemPatientId"].ToString())); } else { myError.Visible = true; ((Label)myError.FindControl("labelError")).Text = myHemogram.myError.getLastError(); } } } } for(int i=0;i < myPharmaCistGrid.Items.Count; i++) { myItem = myPharmaCistGrid.Items[i]; if ((myItem.ItemType != ListItemType.Header) && (myItem.ItemType != ListItemType.Footer) && (myItem.ItemType != ListItemType.Separator)) { if (((CheckBox)myItem.FindControl("cbSelectRow2")).Checked==true) { if (myHemogram.addHemogram(textHemHemogramDate.Text, textHemLokosit.Text, textHemNNS.Text, textHemEOS.Text, textHemBAS.Text, textHemLIM.Text, textHemMON.Text, textHemDoze.Text, textHemPack1.Text, textHemPack2.Text)) { myError.Visible = false; this.Response.Redirect("patient.aspx?patientNumber=" + Request.QueryString["patientNumber"].ToString()); bindMyHemogram(Int32.Parse(Request.QueryString["hemPatientId"].ToString())); } else { myError.Visible = true; ((Label)myError.FindControl("labelError")).Text = myHemogram.myError.getLastError(); } } } } } private void myPhysicianGrid_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { CheckBox myCheckBox; if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { myCheckBox = (CheckBox)e.Item.FindControl("cbSelectRow1"); myCheckBox.Attributes.Add("OnClick", "CCA(this, 'selectRow', 'recipe');"); } } private void myPharmaCistGrid_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { CheckBox myCheckBox; if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { myCheckBox = (CheckBox)e.Item.FindControl("cbSelectRow2"); myCheckBox.Attributes.Add("OnClick", "CCA(this, 'selectRow', 'recipe');"); } } ---------Datagrids:------------------------ -----------------
Reply
Answers (
1
)
How put Invert Comma (") in C#
Proble with ClientSponsor