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
kaushik guru
NA
252
30.1k
selecteditem.value always shows null or zero
Apr 8 2020 11:02 PM
i am selecting a value from dropdown and passing it to store procedure but the selected index value always becomes null or zero . kindly guide
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace DMS.Report
{
public partial class UserMatrixRights : System.Web.UI.Page
{
DataSet ds = null;
protected void Page_Load(object sender, EventArgs e)
{
if(ddlroles.Text == "Users")
{
LblError.Visible = false;
lblusers.Text = "Users";
Loadusers();
}
else if (ddlroles.Text == "Roles")
{
LblError.Visible = false;
lblusers.Text = "Roles";
Loadroles();
}
}
private void Loadusers()
{
try
{
DataSet dsUsers = null;
using (GeneralInfo GenInfo = new GeneralInfo(General.ConnString()))
{
dsUsers = GenInfo.GetAllUsers();
if (dsUsers != null)
{
if (dsUsers.Tables.Count > 0)
{
if (dsUsers.Tables[0].Rows.Count > 0)
{
DataRow drUsersLoad;
drUsersLoad = dsUsers.Tables[0].NewRow();
drUsersLoad["User_RoleId"] = 0;
drUsersLoad["User_Name"] = "ALL";
dsUsers.Tables[0].Rows.InsertAt(drUsersLoad, 0);
ddusers.DataTextField = "User_Name";
ddusers.DataValueField = "User_RoleId";
ddusers.DataSource = dsUsers.Tables[0];
ddusers.DataSource = dsUsers.Tables[0];
ddusers.DataBind();
// ddusers.Items.Insert(0, "--Select--");
}
}
}
}
}
catch (GeneralInfoException GeneralEx)
{
LblError.Text = GeneralEx.ErrorDescription;
//log.Error("AssetMaintenance_LoadCategory_Details", GeneralEx);
}
catch (Exception ex)
{
LblError.Text = GeneralException.Errcode(ex);
//log.Error("AssetMaintenance_LoadCategory_Details", ex);
}
}
private void Loadroles()
{
try
{
DataSet dsUsersgp = null;
using (GeneralInfo GenInfo = new GeneralInfo(General.ConnString()))
{
dsUsersgp = GenInfo.GetAllUsersGroups();
if (dsUsersgp != null)
{
if (dsUsersgp.Tables.Count > 0)
{
if (dsUsersgp.Tables[0].Rows.Count > 0)
{
DataRow drUsersgpLoad;
drUsersgpLoad = dsUsersgp.Tables[0].NewRow();
drUsersgpLoad["Role_Id"] = 0;
drUsersgpLoad["Role_Description"] = "ALL";
dsUsersgp.Tables[0].Rows.InsertAt(drUsersgpLoad, 0);
ddusers.DataTextField = "Role_Description";
ddusers.DataValueField = "Role_Id";
ddusers.DataSource = dsUsersgp.Tables[0];
ddusers.DataBind();
}
}
}
}
}
catch (GeneralInfoException GeneralEx)
{
LblError.Text = GeneralEx.ErrorDescription;
//log.Error("AssetMaintenance_LoadCategory_Details", GeneralEx);
}
catch (Exception ex)
{
LblError.Text = GeneralException.Errcode(ex);
//log.Error("AssetMaintenance_LoadCategory_Details", ex);
}
}
protected void BtnView_Click(object sender, ImageClickEventArgs e)
{
try
{
getreport();
}
catch (Exception ex)
{
}
}
private void getreport()
{
string sValue = ddusers.SelectedItem.Value;
(sValue always becomes null or 0)
if (ddlroles.Text == "Users")
{
using (MasterManagement mMgmt = new MasterManagement(General.ConnString()))
{
ds = mMgmt.GetUserReport(sValue);
}
}
else
{
}
}
}
}
Reply
Answers (
1
)
Need help with ASP.NET Core 3.1 API for use with Android
different zone c# coding problem